# 502 error

**URL:** <https://www.ruby-forum.com/t/502-error/221428>\
**Category:** NGINX\
**Created:** [July 13, 2012, 6:19pm UTC](https://www.ruby-forum.com/t/502-error/221428 "2012-07-13T18:19:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [July 13, 2012, 6:19pm UTC](https://www.ruby-forum.com/t/502-error/221428/1 "2012-07-13T18:19:49Z")

</div>

Hello all,

have question about 502 Bad Gateway error. Does it generated by Nginx,  
or by backend server? If it with in Nginx which module generates it?

Thanks.  
M.

Posted at Nginx Forum:

> **[502 error](https://forum.nginx.org/read.php?2,228575,228575#msg-228575)**
>
> Hello all, have question about 502 Bad Gateway error. Does it generated by Nginx, or by backend server? If it with in Nginx which module generates it? Thanks. M.

---

<div class="post-metadata">

**Author:** ![munkhabi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/13edae/32.png) [@munkhabi](https://www.ruby-forum.com/u/munkhabi)\
**Post date:** [July 13, 2012, 10:02pm UTC](https://www.ruby-forum.com/t/502-error/221428/2 "2012-07-13T22:02:26Z")

</div>

Hello!

On Fri, Jul 13, 2012 at 12:19:25PM -0400, munkhabi wrote:

> Hello all,
> 
> have question about 502 Bad Gateway error. Does it generated by Nginx,  
> or by backend server? If it with in Nginx which module generates it?

The 502 is a generic error which is generated if upstream server  
doesn’t respond properly, see here:

> **[RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1 | RFC Editor](https://www.rfc-editor.org/info/rfc2616/)**
>
> HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as "HTTP/1.1", and is an update to RFC 2068. \[STANDARDS-TRACK\]

It may be generated by nginx (if error happens while talking to a  
backend), as well as by a backend server (if it talks to some  
backends too, and error happens there).

In nginx it’s generated by the upstream module, i.e. it might  
happen if you use proxy, fastcgi, scgi, uwsgi or memcached.

Maxim D.
