Record the full message and conditions
Connection refused, Connection timed out and Invalid session should not be treated as one error simply because they appear when joining. Save a screenshot, Java Edition version, server address and attempt time. If the message concerns an account session, investigate sign-in rather than immediately changing network settings.
Verify the server and joining method
The official Java Edition route is Multiplayer, then Direct Connection or Add Server with the address supplied by the owner. Compare the address and required parameters with their instructions. Ask the administrator whether the server is running and accepts your version and setup. An accessible website does not establish that its game server is reachable.
Separate one failing server from a wider issue
Ask whether another participant can join the same server and compare with another server you are permitted to use. Do not perform bulk checks of unrelated addresses. If only one destination fails, give its owner the error and timestamp; if several fail, continue investigating your device and connection.
Restart the game and check connectivity
Minecraft's Java guidance includes reopening the game and restarting the device. Check ordinary websites and pause background downloads or video streams for comparison. On Wi-Fi, try moving nearer the router; a stationary computer can be compared using Ethernet. Working web browsing does not prove a particular game server is available.
Review network settings you changed
If DNS was configured manually, Minecraft Support suggests returning it to automatic selection. Review the game's firewall rules and any VPN settings so the connection is not blocked. Ask the administrator about restrictions on a work or school network. Do not disable protection entirely or open every port for one error.
Keep results for the administrator or support
Change one condition at a time and record the result with the same address and version and a new attempt time. Note whether other players fail and what changed when comparing connections. This is more useful than simply saying getsockopt is broken. Deleting worlds, reinstalling Windows and arbitrary public DNS servers are not part of these checks.