Understanding Timeouts
Connection timeout means the remote server never responded within time limit.
Quick Network Tests
# Ping test (ICMP)
ping -c 4 TARGET_IP
# TCP connection test
nc -zv TARGET_IP PORT
telnet TARGET_IP PORT
# Trace route
traceroute TARGET_IP
mtr TARGET_IP
Common Causes
1. Firewall Blocking
Check both client and server firewalls:
# Server-side (UFW)
sudo ufw status verbose
# Server-side (iptables)
sudo iptables -L -n -v
2. Server Overloaded
High load can delay responses beyond timeout:
top
uptime
netstat -an | grep ESTABLISHED | wc -l
3. Network Congestion
Use mtr to see packet loss at any hop:
mtr --report TARGET_IP
4. MTU Issues
Packet fragmentation can cause timeouts:
# Test MTU
ping -M do -s 1472 TARGET_IP
# Reduce MTU if needed (via MSS clamping in iptables)
5. Routing Problems
Check for asymmetric routing or BGP issues.
Application-Specific Timeouts
Increase timeout values:
# Nginx
proxy_read_timeout 300s;
proxy_connect_timeout 300s;
# PHP
max_execution_time = 300
# MySQL
connect_timeout = 300
wait_timeout = 300
Investigate from Both Ends
Test same port from different client (mobile hotspot). If works, issue is your local network.