Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx 504 gateway timeout [closed]

Tags:

nginx

gateway

I tried the suggestions at:

How do I prevent a Gateway Timeout with FastCGI on Nginx

nginx.conf (inside of http section {})

#prevent gateway timeout
client_header_timeout 1000000;
client_body_timeout 1000000;
send_timeout 1000000;
fastcgi_read_timeout 1000000;

But after about 60 seconds I get an error 504 gateway timeout. We have nginxx in front of apache, so I am not sure if apache is causing the error, but we get a 504 gateway timeout that is clearly from nginx

like image 200
Chris Muench Avatar asked Oct 18 '25 14:10

Chris Muench


1 Answers

The definition of the 504 HTTP response code says: "The server was acting as a gateway or proxy and did not receive a timely response from the upstream server." So, it makes sense to start by treating this an issue with the backend server.

You should check what happens you make a request directly to the backend server. How long does it take to respond?

Note that with Apache you can configure your logs to include the time to taken to process the request. See the %t and %T options for mod_log_config.

If Nginx can access the backend server, so can you from the command line. Here's an example syntax to execute and time a request:

time -p GET -H 'Host: publicname.com'  http://127.0.0.1:8080/path/to/request

The "GET" tool is part of the libwww-perl package available on Ubuntu-like Linux distributions. By sending a "Host:" header, you are generating a request much like Nginx would.

like image 104
Mark Stosberg Avatar answered Oct 21 '25 00:10

Mark Stosberg