Question

504 Wordpress Errors with Nginx and PHP5-FPM

Posted December 21, 2017 1.5k views
Nginx Ubuntu PHP WordPress

My Wordpress blog has been getting 504 errors practically every time I try to load a page in the admin panel or on the site. I used to get those occasionally but now it’s happening all the time.

My plan has 1 CPU and 1GB memory. I’m running the blog on an Ubuntu 14.04 server with nginx, mysql, and php5-fpm.

The nginx error logs show:

[error] 4405#0: *191 upstream timed out (110: Connection timed out) while reading response header from upstream, client: w.x.y.z, server: a.b.c.d, request: "GET /page-name/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "my.domain", referrer: "http://my.domain/blog/"

This is my site’s nginx conf file:

server {
    listen 80;
    listen [::]:80 default_server ipv6only=on;

    root /var/www/html;
    index index.php index.html index.htm;

    server_name w.x.y.z;

    location / {
          try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

}

This is my php5 pool.d/www.conf file:

[www]

user = www-data
group = www-data

listen = 127.0.0.1:9000

listen.owner = www-data
listen.group = www-data
listen.mode = 0660

pm = dynamic

pm.max_children = 5

pm.start_servers = 2

pm.min_spare_servers = 1

pm.max_spare_servers = 3

pm.max_requests = 200

request_terminate_timeout = 30s

chdir = /

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

Hi @rwdev,

Your issue is related to a FastCGI problem. To resolve it please follow these steps:

  • Check whether the file /etc/nginx/conf.d/timeout.conf exists (if not, create it) and make the contents of that file
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;

reload Nginx configuration with the command: service nginx reload (or equivalently, run the command: nginx -s reload)

  • Verify that the files /etc/nginx/fastcgi.conf and /etc/nginx/fastcgi_params contain the line
fastcgi_param SCRIPT_NAME $fastcgi_script_name;

as this is related to one of the error messages in the log output that you provided.

Regards,
KDSys

Submit an Answer