(The image above may vary)
If you're unable to connect to your server and receive the 504, 503, or 502 error message. This means your server is unable to connect to the Minecraft.net authentication servers preventing the server from confirming you are who you say you are.
When Minecraft.net's auhentication system is down, all servers will be unable to authenticate players and will not let them join. You'll have to wait till Minecraft.net authentication server is online again.
Sometimes if Minecraft.net is just acting slow. If this is the case, keep trying to join the server and eventually you'll be able to join.
If you find Minecraft.net's just acting slow, you may be able to keep trying to join the server until it lets you in.