I usually had this issue about a year ago.
Try updating to a newer version of minecraft (for example, 1.12.1).
If that doesn't help, or you are already using that version, then close your minecraft, open the laucher, log out of your account and then log back into your account again. Then connect to the server.
If none of that worked, try restarting your router and/or computer.
If it still doesn't work, then wait a few hours and try again.
Hope this helps!