Connection timed out

The Connection timed out error means that a network connection attempt did not receive a response within the allowed time limit. The client system sent a request, but the destination host or service did not reply before the timeout period expired. This error commonly occurs in Linux and Windows systems, Java and Spring Boot applications, Docker containers, databases, APIs, and remote servers.

When does this error occur?

  • Connecting to a remote server that is slow or unreachable
  • Accessing a database service over the network
  • Calling an external API from an application
  • Communication issues between containers or services
  • Network traffic blocked by firewall or routing rules

Root cause of Connection timed out

This error occurs at the OS and network level when a TCP or UDP connection does not receive a response within the configured timeout window. The destination system may be offline, overloaded, blocked by firewall rules, misconfigured, or affected by high network latency.

How to fix the error (step-by-step)

Linux / macOS

Verify network reachability and port availability.

ping <hostname-or-ip>
nc -vz <hostname> <port>

Windows

Check connectivity and firewall behavior.

ping <hostname-or-ip>
Test-NetConnection -ComputerName <hostname> -Port <port>

Java / Spring Boot

Increase connection timeout settings when calling remote services.

System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");

Docker / containers

Ensure containers share the correct network and exposed ports.

docker network ls
docker network inspect <network-name>

Database / network services

Confirm the service is running and listening on the expected port.

netstat -an | grep LISTEN

Verify the fix

Retry the connection after applying changes. The service should respond within the expected time and the timeout error should no longer appear in logs or client output.

Common mistakes to avoid

  • Assuming the service is down without checking firewall rules
  • Using incorrect hostnames or ports
  • Setting timeout values too low
  • Ignoring DNS resolution failures
  • Testing from only one network location

Quick tip

Always verify basic network connectivity before adjusting application-level timeout settings.

FAQ

Q: Is Connection timed out the same as Connection refused?

A: No. A timeout means no response was received, while a refusal means the server actively rejected the connection.

Q: Can network latency cause this error?

A: Yes. High latency or packet loss can delay responses beyond the timeout limit.

Conclusion

The Connection timed out error indicates a delayed or blocked network response. Resolving connectivity, firewall, and timeout configuration issues typically fixes it. Check related root error references on ErrorFixHub for further troubleshooting.

Comments

Popular posts from this blog

Port already in use

Permission denied

No such file or directory