Saturday, April 19, 2014

Fix Nginx error upstream timed out when upgrading Wordpress

Today, I tried to upgrade my blog to the latest version of wordpress, 3.9. But, for some reasons, the page was just blank after I click the Update button in the dashboard. I tracked down the error logs of Nginx and found this error message:

2014/04/19 09:58:28 [error] 2447#0: *14 upstream timed out (110: Connection timed out) while reading upstream, client:, server:, request: "POST /wp-admin/update-core.php?action=do-core-upgrade HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "", referrer: ""

So, the issue is caused by the short timeout setting of my nginx server block. To fix that, try to add these 2 red lines to the server block:


      location / {
              proxy_read_timeout 300;


        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
                # timeout
                fastcgi_read_timeout 300s;


Restart nginx service and try to update wordpress again. It should work:

$ sudo service nginx restart


P/S: I used 300 in my case, you can always adjust the time to whatever you need depends on your server requirement or setup.