Nginx Wordpress error 504

There was a site on Wordpress worked for about 5 months without any complaints. Recently I started to consistently produce an error 502. In this error logs:

2016/01/18 03:58:54 [error] 13245#0: *125039 connect()  
 to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream,  
 client:, server:, request: "POST /xmlrpc.php HTTP/1.0", upstream: 
 "fastcgi://unix:/var/run/php5-fpm.sock:", host: ""

I found the following advice: Solution I restart the server - everything worked, the next day there was a 504 error. The log was as follows:

2016/01/19 02:37:38 [error] 3677#0: *5484 upstream timed out (110: Connection timed out)  
 while reading response header from upstream, client:, server:, request:  
 "GET /done_battles/11/ HTTP/1.1", upstream: "fastcgi://", host: "  

Before the error was a pair of triple the following messages:

2016/01/18 04:43:23 [crit] 13245#0: *125168 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory)  
 while connecting to upstream, client:, server:, request: "GET /favicon.ico HTTP/1.1",  
 upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "", referrer: ""  


user www-data; worker_processes 4; pid /run/;

events { worker_connections 768; # multi_accept on; }

http {

sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off;

# server_names_hash_bucket_size 64; # server_name_in_redirect off;

include /etc/nginx/mime.types; default_type application/octet-stream;

## # Logging Settings ##

access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log;

## # Gzip Settings ##

gzip on; gzip_disable "msie6";

# gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

## # nginx-naxsi config ## # Uncomment it if you installed nginx-naxsi ##

#include /etc/nginx/naxsi_core.rules;

## # nginx-passenger config ## # Uncomment it if you installed nginx-passenger ## #passenger_root /usr; #passenger_ruby /usr/bin/ruby;

## # Virtual Host Configs ##

include /etc/nginx/conf.d/.conf; include /etc/nginx/sites-enabled/; }

I am so sorry for my bad english.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Not sure if you googled, but try solution 2a from this link:

Still a learner my self but it seems your nginx can’t find the /var/run/php5-fpm.sock location. Try the fix from the guide and let me know how it goes ^^

Just wanted to chime in here. I also had a similar problem (tried to update wordpress, site went down; nginx log pushed out a fastcgi upstream read error related to headers).

Had tried rebooting php5-fpm, nginx, and server with no luck.

The 2b. fix listed at the site above ( worked for me like a charm.