There are several ways to fix this problem.
- Restart Minecraft.
- Restart your computer.
- Restart your router (turn it off and on again)
- Try to join other servers. If this error only happens on a certain server, it’s likely that it’s the hosts fault.
- If none of the steps worked, try fixing your firewall settings.
- Go to your Windows search bar and type “Windows Security” and select it when it pops up.
- On the page that opens select the “Firewall & Network protection” part.On the next page select the text “Allow an app through firewall”.
- On the page that opens up select “Change Settings” and click “Yes” on the warning prompt.
- Now look further down the page where you will now be able to interact with the previously greyed out “Allow another App”.
- There will be a small pop up window with a button labeled “Browse…”, select this and then navigate to the place where you have Minecraft installed.
- In the Minecraft folder select the MinecraftLauncher file and click “Open”.
- Repeat the steps above and this time navigate to where you have your Minecraft Server installed and go to the folder “MinecraftServer” and in it select both Java executable files and open those too.
- Lastly, stay on the Change Settings page, but this time scroll down the list of allowed apps and features until we see the entries labeled “Java(TM ) Platform SE binary”. Here tag all the checkmarks for “Private” at the very least and “Public” too if you run a server and want people to connect from outside our network.
Start Minecraft again and check if you now have access to the server.
If nothing worked, consider contacting Mojang support.