Nginx + PHP5-FPM error 110: Connection timed out

June 13, 2016 12.9k views
Nginx PHP

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://", 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.

2 Answers

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?

  • I actually posted the old config file before making these changes, so that line for the fastcgi_read_timeout is in there. As for the nginx.conf, there is an if statement on line 6. It was modified by the plugin iThemes Security in Wordpress to add a blacklist of known malicious hosts.

  • I edited the file to take out what iThemes Security added and it worked fine.

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 fastcgireadtimeout.

Have another answer? Share your knowledge.