Error upstream timed out. What is wrong with my setup?

I am running wordpress 3.9.1 on a 2GB ram / 2x CPU digitalocean vps with nginx and php5-fpm on tcp/ip 127.0.0.1:9000 under debian 7 x64. I am experiencing massive 504 gateway timeouts.
nginx log output is:
upstream timed out (110: Connection timed out) while connecting to upstream or
upstream timed out (110: Connection timed out) while reading response header from upstream

www.conf:
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 25
pm.start_servers = 4
pm.min_spare_servers = 4
pm.max_spare_servers = 8
pm.max_requests = 200
listen_backlog = 65536
request_terminate_timeout = 30

php.ini:
max_execution_time = 30

nginx.conf:
worker_processes 2;
worker_connections 1024;
client_max_body_size 10M;
fastcgi_read_timeout 30s;
client_header_timeout 30s;
client_body_timeout 30s;
fastcgi_send_timeout 30s;    
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
keepalive_timeout 65;
gzip on;

The recommended settings of DO for the sysctl.conf are:    
# Digital Ocean Recommended Settings:
net.core.wmem_max=12582912
net.core.rmem_max=12582912
net.ipv4.tcp_rmem= 10240 87380 12582912
net.ipv4.tcp_wmem= 10240 87380 12582912

the following was removed completely:
php5-fpm.conf (/etc/nginx/conf.d/):
upstream php5-fpm-sock { 
server unix:/var/run/php5-fpm.sock; 
}

I also tried to disable my plugins with no luck. The site becomes unresponsive while the wordpress dashboard shows “connection lost” message and eventually 504 gateway timeout.

Read More

Anyone with a similar experience?
Any suggestions would be appreciated.
Thanks.

Related posts

Leave a Reply

1 comment

  1. Nginx worker_processes should correlate directly to the CPU threads; since you have a 2 core CPU then you should have 2 worker_processes threads.

    Next, try increasing the php-fpm servers to x4 of CPU threads. Something like:

    pm.start_servers = 4
    pm.min_spare_servers = 4
    pm.max_spare_servers = 8
    

    Also, nginx is complaining of the upstream timeouts. Do you have any upstream confs/servers ?