Can't connect

Okay, so when I try to connect to a server, it starts loading and stops for a long while on the “Retrieving server info” and then it goes to “Sendig client info” and it stays there until it disconnects. It loads until there are 4 blocks left from the bar. And the balls around the Garrys mod logo just keep circling around it. What do I have to do?