How to Solve Nginx Error "504 Gateway Time-out"

 

When I was editing some staff and then Nginx showed an error reads "504 Gateway Time-out", for more details, I checked the Apache and Nginx log. And there was a log showed "upstream timed out (110: Connection timed out) while reading response header from upstream".

After checked the log, I have a clue in my mind. I am using Plesk as my server management tool, every Plesk comes with Nginx and Apache together as web server application, Nginx as proxy and pass requests to Apache, Apache do the background processing and then return the results to Nginx. Gateway time-out means Nginx had sent requests to Apache but didn't get responses from Apache in time.

Now, it's pretty easy to solve the problem. Nginx waits 60 seconds to get the results, if Apache were not respond to the requests, Nginx would show 504 Gateway time-out error. So, what we do is to change the wait time a little bit longer than 60s.


 

In Plesk, Navigate to Domains > example.com > Apache & nginx settings > Additional nginx directives, add the following command and apply.

 proxy_read_timeout 180s;

The command above changed the wait time from 60s to 180s, if it were not long enough, you may change to 600s or even more.

Comments

Popular posts from this blog

How to Enable HSTS in Webmin

ONE-CLICK L2TP/IPSec VPN Installer

Alphabet Sold Google Domains to Squarespace