# How to distinguish if nginx generated a 504 error or upstream returned it?

**URL:** <https://www.ruby-forum.com/t/how-to-distinguish-if-nginx-generated-a-504-error-or-upstream-returned-it/246091>\
**Category:** NGINX\
**Created:** [August 21, 2013, 12:44am UTC](https://www.ruby-forum.com/t/how-to-distinguish-if-nginx-generated-a-504-error-or-upstream-returned-it/246091 "2013-08-21T00:44:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [August 21, 2013, 12:44am UTC](https://www.ruby-forum.com/t/how-to-distinguish-if-nginx-generated-a-504-error-or-upstream-returned-it/246091/1 "2013-08-21T00:44:27Z")

</div>

Hello !

I run nginx as a reverse proxy and send requests to an upstream server,  
the problem is according to my logs sometimes i start seeing this:

[499] [-] [0] [11602] [xx.126.55.81] [GET /weblogin/ HTTP/1.1]

or

[504] [-] [0] [11602] [xx.126.55.81] [GET /weblogin/ HTTP/1.1]

The first field is the $status, the second is the  
$upstream\_cache\_status. So I know for a fact these two requests did go  
to the upstream server however what i dont know is who returned the 504  
and 499 codes. My server or the upstream ?

I know I can implement $request\_time to try to “guess” using my timeouts  
and assume if they where generated below them that it may be the  
upstream that for whatever reason served the request with that code.

How can I be sure?

Alex

---

<div class="post-metadata">

**Author:** ![Alex\_Flex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@Alex\_Flex](https://www.ruby-forum.com/u/Alex_Flex)\
**Post date:** [August 21, 2013, 12:44pm UTC](https://www.ruby-forum.com/t/how-to-distinguish-if-nginx-generated-a-504-error-or-upstream-returned-it/246091/2 "2013-08-21T12:44:16Z")

</div>

Hello!

On Tue, Aug 20, 2013 at 04:43:40PM -0600, Alex Flex wrote:

> [504] [-] [0] [11602] [xx.126.55.81] [GET /weblogin/ HTTP/1.1]
> 
> How can I be sure?

$upstream\_status?

> **[Module ngx\_http\_upstream\_module](http://nginx.org/en/docs/http/ngx_http_upstream_module.html#variables)**
>
> The ngx\_http\_upstream\_module module is used to define groups of servers that can be referenced by the proxy\_pass, fastcgi\_pass, uwsgi\_pass, scgi\_pass, memcached\_pass, and grpc\_pass directives.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**
