The getsockopt message alone does not tell you at what stage the connection was lost. Read the entire statement on the screen. Connection refused and Connection timed out require different controls.
Step by step
-
Get the address from the server's current announcement, not from the old entry in the multiplayer list. In Java, enter the address in the format
play.example.net:25566if required. In Bedrock, the address and port are written in separate boxes. -
Connect to another known server with the same Minecraft client. If you're only getting errors on one target, review that target first. If you get the same error on every target, focus on local network or client settings.
-
Identify the target with the correct edition. If DNS is resolving but the Java TCP connection is rejected, have the administrator check the port and process. Also try accessing the server from a different network when it times out.
-
When you try the connection again, note the time and exact error text. If the administrator can find that minute in the server log, the request has at least reached the application.
Keep in mind
Even if the status query works, whitelisting, version and account verification may prevent game login.