Question

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: xxx.xxx.xxx.xxx, server: websitename.net, request: "GET /wp-login.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "websitename.net", referrer: "https://websitename.net/wp-login.php"

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.

Subscribe
Share

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

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.

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?