I have to close, open, close, open minecraft multiple times before it says "logging in". If it doesn't say that instantly, I know it'll just time out. Once I log in, the world doesn't load, the chat doesn't load and I time out within 30 seconds. Send halp.
Probably your wifi. That's what happens. Also, it happens when the server is filled with people and is lagging.
This happens to me too. I'm in the void, press f5, and you cannot see me. I disconnect and I refresh server list and try again until I get "green bars" then cross my fingers. 2/10 times I get this problem.
If its not your Wi-Fi it may be your Minecraft itself. If you still have issues with it, you can backup all of your Minecraft data to a USB port or to your cloud [if your computer has one]. All this does is back up any Minecraft worlds you have under single player. Delete your Minecraft folder. Then you can uninstall Minecraft and re install it. It will take maybe 5-10 minutes to complete. (If you have Minecraft Forge it should save if you take out your mods folder and drag it onto desktop, then just put it onto your new Minecraft folder after.) Then just take your world files [if any] out and place them in the correct area of the folder.
I agree with CoolCreeper20202, uninstal and reinstal (Save your files). If that wont work, I noticed Minecraft servers were unestable this last week (I think it is totally a Minecraft problem, not from the server).