Nginx + PHP5-FPM error 110: Connection timed out

I have been getting this error and cannot figure out why. Here is the exact error:

2016/06/13 19:49:55 [error] 1623#0: *977708 upstream timed out (110: Connection timed out) while reading response header from upstream, client:, server:, request: "GET /wp-login.php HTTP/1.1", upstream: "fastcgi://", host: "", referrer: ""

I didn’t make any changes to break it. It started after I saw this event in the log file:

2016/06/09 21:00:00 [emerg] 14982#0: "if" directive is not allowed here in /etc/nginx/nginx.conf:6

I have tried this, this, and this but none of it has made a difference. Here is my config file.

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.

Here an aritcle that I wrote recently that addresses this problem as well Nginx upstream timed out (why and how to fix)

As for you if error, that could prevent Nginx from reloading config, maybe because of it you couldn’t see the results of fastcgi_read_timeout.

These two errors may or may not be related.

For the timeout error, as referenced in this article try adding the line:

fastcgi_read_timeout 120;

to the nginx configuration block with the rest of your fastcgi params. (the block probably starts with location ~* .php$ {...

For the nginx.conf error, it sounds like you have some kind of nginx configuration error. What is the code on line 6? Are you using an if statement outside of a location {} block in the configuration?