DB / Nginx/Apache/Load Balancer / 504
WARNING
Nginx/Apache/Load Balancer Gateway Timeout
The server, acting as a gateway or proxy, did not receive a timely response from an upstream server.
Common Causes
- Upstream server (application, database, API) is overloaded or has crashed.
- Network latency or connectivity issues between the proxy and upstream server.
- Proxy server timeout settings (e.g., proxy_read_timeout) are too low for the upstream response.
How to Fix
1 Increase Proxy Timeout Settings (Nginx)
Increase the timeout values for reading from the upstream server in your Nginx configuration.
BASH
$ location / {
proxy_pass http://upstream_backend;
proxy_read_timeout 300s; # Increase from default 60s
proxy_connect_timeout 75s;
} 2 Check Upstream Server Health
Verify the upstream application or service is running and responsive. Check logs for errors.
BASH
$ # Check if the service is running
systemctl status your-application
# Check application logs
journalctl -u your-application -f
# Test connectivity to the upstream port
telnet upstream-server-ip 8080 3 Scale Upstream Resources
If the upstream server is overloaded, scale the application horizontally (add more instances) or vertically (increase CPU/RAM).
BASH
$ # Example: Scale a Kubernetes deployment
kubectl scale deployment/my-app --replicas=5
# Check resource usage on the upstream server
top
htop