Let's try to figure this out.
I restarted my game three times. That didn't work. I switched my character to Ana; that didn't work. I got the error code saying that I lost connection to the server and tried joining a game. Still wasn't working. I then restarted the game again and did the same routine. I switched my character to Reverend and then went to the server browser and joined a hard lobby with one player and it finally worked. Maybe it doesn't have to do with switching characters, but the player count on the server or the difficulty of the server?
I'm not the one to know this stuff I'm just trying to think of solutions.