There's a good chance that the firewall on your computer is restricting the game from using your internet connection. Since Minecraft will be unable to access its servers, you will get an error message.