# Nginx fastcgi\_intercept\_errors

**URL:** <https://www.ruby-forum.com/t/nginx-fastcgi-intercept-errors/237783>\
**Category:** NGINX\
**Created:** [November 29, 2013, 12:36pm UTC](https://www.ruby-forum.com/t/nginx-fastcgi-intercept-errors/237783 "2013-11-29T12:36:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [November 29, 2013, 12:36pm UTC](https://www.ruby-forum.com/t/nginx-fastcgi-intercept-errors/237783/1 "2013-11-29T12:36:51Z")

</div>

nginx/1.5.4 doesnt intercept fastcgi errors.  
location / {  
…  
fastcgi\_pass bg;  
error\_page 500 502 503 504 408 404 =204 /204.htm;  
fastcgi\_intercept\_errors on;

…  
}

However in root location access log we still see

91.192.148.232 - - [29/Nov/2013:13:39:20 +0400] “POST / HTTP/1.1” 504  
182  
“-” “-” “0.138”

And tcpdump capture shows that we still send 504:

Py…HTTP/1.1 504 Gateway Time-out  
Server: nginx/1.5.4  
Date: Fri, 29 Nov 2013 09:42:12 GMT  
Content-Type: text/html  
Content-Length: 182  
Connection: keep-alive

504 Gateway Time-out
# 504 Gateway Time-out

* * *
nginx/1.5.4

What can be wrong here?

Thanks,  
OK

---

<div class="post-metadata">

**Author:** ![Oleg\_VSKhrustov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@Oleg\_VSKhrustov](https://www.ruby-forum.com/u/Oleg_VSKhrustov)\
**Post date:** [November 29, 2013, 2:01pm UTC](https://www.ruby-forum.com/t/nginx-fastcgi-intercept-errors/237783/2 "2013-11-29T14:01:00Z")

</div>

Hello!

On Fri, Nov 29, 2013 at 03:36:18PM +0400, Oleg V. Khrustov wrote:

> However in root location access log we still see
> 
> 91.192.148.232 - - [29/Nov/2013:13:39:20 +0400] “POST / HTTP/1.1” 504 182  
> “-” “-” “0.138”
> 
> And tcpdump capture shows that we still send 504:
> 
> Py…HTTP/1.1 504 Gateway Time-out  
> Server: nginx/1.5.4

[…]

> What can be wrong here?

Most likely reasons, in no particular order:

- You’ve forgot to reload configuration, or the configuration was  
rejected due to errors and you’ve missed it.

- The request is handled in other location and/or server, not  
the one you are looking at.

–  
Maxim D.  
[http://nginx.org/en/donation.html](http://nginx.org/en/donation.html)

---

<div class="post-metadata">

**Author:** ![Oleg\_VSKhrustov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@Oleg\_VSKhrustov](https://www.ruby-forum.com/u/Oleg_VSKhrustov)\
**Post date:** [November 29, 2013, 2:03pm UTC](https://www.ruby-forum.com/t/nginx-fastcgi-intercept-errors/237783/3 "2013-11-29T14:03:21Z")

</div>

Hello!

On Fri, Nov 29, 2013 at 04:59:56PM +0400, Maxim D. wrote:

> > Py…HTTP/1.1 504 Gateway Time-out
> 
> - The request is handled in other location and/or server, not  
> the one you are looking at.

Another possible one, after looking into your next question:

- You’ve forgot to add a location to handle /204.htm, and it’s  
passed to fastcgi backend again, and this again results in 504.  
As by default recursive\_error\_pages is disabled, the error is  
returned to a client.

–  
Maxim D.  
[http://nginx.org/en/donation.html](http://nginx.org/en/donation.html)

---

<div class="post-metadata">

**Author:** ![Oleg\_VSKhrustov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@Oleg\_VSKhrustov](https://www.ruby-forum.com/u/Oleg_VSKhrustov)\
**Post date:** [November 29, 2013, 2:32pm UTC](https://www.ruby-forum.com/t/nginx-fastcgi-intercept-errors/237783/4 "2013-11-29T14:32:34Z")

</div>

Many thanks, works like a charm. The reason is Wrong location settings.

---

<div class="post-metadata">

**Author:** ![Oleg\_VSKhrustov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@Oleg\_VSKhrustov](https://www.ruby-forum.com/u/Oleg_VSKhrustov)\
**Post date:** [November 29, 2013, 2:06pm UTC](https://www.ruby-forum.com/t/nginx-fastcgi-intercept-errors/237783/5 "2013-11-29T14:06:16Z")

</div>

1. /etc/init.d/nginx configtest  
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok  
nginx: configuration file /etc/nginx/nginx.conf test is successful

It was definitely reloaded prior doing any tests.

1. I have a separate access log file for this specific (root) location  
with custon log format where I captured 504 response. It is set only  
for  
root location where I captured unexpected response code.

Thanks,  
OK
