
Quick answer: getsockopt is not a Minecraft problem and not a mod problem. It is Java asking your operating system how a connection attempt ended, and printing the answer. The useful part is the word in front of it. Timed out means your packets left and nothing came back. Connection refused means something answered and said no. Network is unreachable means your machine could not even try. Each one points at a different cause, and reading it correctly saves you hours of changing the wrong settings.
Most guides for this error tell you to port forward and allow Java through the firewall. That is sometimes right, but it is guessing. This page explains how to tell which one you actually have.
What getsockopt really is
When Minecraft connects to a server, Java opens a non blocking socket and asks the operating system to start a TCP connection. It then calls getsockopt to collect the result. So the error is simply the OS verdict passed upward, with the syscall name attached. That is why the same three words show up on Windows, Linux and macOS, on vanilla and on every modpack, and why reinstalling Minecraft never helps.
The three variants you will see:
| Message | What the network did | What that rules out |
|---|---|---|
Connection timed out: getsockopt | Packets sent, no reply at all | The port is not open, or traffic is being dropped silently |
Connection refused: getsockopt | A machine replied with TCP RST | The host is reachable, nothing is listening on that port |
Network is unreachable: getsockopt | No route to the address | Wrong address family, usually IPv6 versus IPv4 |
That table is the whole diagnosis. A refused is good news compared to a timeout, because it proves you reached the right machine.
Timed out: nothing answered
Silence means something between you and the server is dropping packets rather than rejecting them. In order of how often it is actually the cause:
The server is not running. Obvious, but check the console shows Done (x.xxxs)! For help, type "help" before you blame the network. A server still generating spawn chunks is not listening yet.
Port 25565 is not forwarded. If the server is on a home connection, the router must forward TCP 25565 to the machine running it. Forward TCP. UDP is only needed if you run Bedrock or a voice chat mod.
The firewall is dropping it. On Windows the rule has to allow the Java binary, not "Minecraft". People allow javaw.exe and miss that a modern server runs under java.exe or OpenJDK Platform Binary. On Linux, sudo ufw allow 25565/tcp.
Your ISP uses CGNAT. This one is worth knowing because no amount of configuration fixes it. If your router's WAN address starts with 100.64. through 100.127., you are behind carrier grade NAT and share a public address with other customers. Port forwarding cannot work, because the port does not belong to you. Check your router's WAN address against your address on a site like whatismyip, and if they differ, that is your answer. Your options are a tunnel service, asking your ISP for a public address, or hosting the server somewhere with a real address.
Refused: something said no
A refusal is a machine actively rejecting the connection. Nothing is listening on that port on that host.
Wrong port in the address. Connecting to example.com uses 25565. If your server runs on another port you must write example.com:25566.
The server bound to localhost only. Check server-ip in server.properties. It should be empty. Blank means bind to all interfaces. If someone set it to 127.0.0.1, the server only accepts connections from the same machine, which is exactly why localhost works while nobody else can get in.
You are pointing at the wrong machine. A dynamic IP that changed, or a DNS record that still points somewhere else.
Network is unreachable: usually IPv6
This one is nearly always an address family mismatch. Your client resolves the hostname to an IPv6 address, your network has no working IPv6 route, and the connection never leaves. Force IPv4 by adding this to your client or launcher JVM arguments:
-Djava.net.preferIPv4Stack=true
If that fixes it, the underlying issue is the IPv6 configuration on your network, not Minecraft.
The trap: it works on localhost but not on your public IP
This comes up constantly and it is not a broken server. From inside your own network, connecting to your own public IP requires the router to loop the traffic back to itself. That feature is called NAT loopback or hairpinning, and plenty of consumer routers do not support it.
So this pattern is normal and expected:
- You, on the same network: use the server's local address, like
192.168.1.20 - Friends, outside: use the public address
If your friends can connect and you cannot, your server is fine. You are just testing it the one way that does not work.
A five minute diagnosis
Work outward. Each step tells you where the problem is not.
- On the server machine, connect to
localhost. Works? The server and Java are fine, this is a network problem. Fails? The server is not actually running or not listening. - On another machine on the same network, connect to the local IP. Works? The server binding and local firewall are fine. Fails? Firewall on the server machine.
- From outside, connect to the public address. Fails here but step 2 worked? Port forwarding or CGNAT.
- Check the WAN address in your router against your actual public address. Different? CGNAT, and steps 1 to 3 will never fix it.
That order matters. Most people start at step 3, get a timeout, and start changing firewall rules that were never the problem.
When the answer is honestly not a setting
We looked at what people actually report when this error comes up, and port forwarding and firewall rules account for most of it. But a real share of cases are people who cannot fix it at all, because they do not control the router, are behind CGNAT, or their ISP blocks inbound connections. Several posts we read were from players sharing a connection they had no admin access to.
If that is you, no guide will help, because the problem is not on your machine. A hosted server sidesteps it entirely: it has its own public address and the port is already open, so there is nothing to forward. That is genuinely the only reason we bring it up here. If you can port forward, do that and keep your money.
FAQ
Is getsockopt a Minecraft bug? No. It is the name of an operating system call that Java uses to read the result of a connection attempt. The error text comes from your OS, not from Minecraft.
Why does it work for my friends but not for me? Almost always NAT loopback. From inside your own network you should use the server's local address, not your public one.
Does reinstalling Minecraft or Java fix it? No. Nothing about this error lives in the game files. Reinstalling changes nothing about routing, firewalls, or port forwarding.
Do I need to forward UDP as well as TCP? For Java Edition, TCP 25565 is enough. Forward UDP as well if you run Bedrock, Geyser, or a voice chat mod that uses its own UDP port.
My router shows an address starting with 100.64. Is that a problem? Yes. That range is carrier grade NAT. You do not have your own public address, so port forwarding cannot work no matter how you configure it.
Related reading: Minecraft server requirements if you are sizing a server, or Minecraft hosting if you have hit the CGNAT wall and need a public address.