Erro 502 Bad Gateway help

Francis Daly francis at
Sat Jul 2 07:25:19 UTC 2016

On Sat, Jul 02, 2016 at 06:21:38AM +0000, yair avendaño wrote:

Hi there,

> Hi I'm setting up a nginx as a reverse proxy but to try to see a site with drupal locally that have shown me 502 Bad Gateway error.

"drupal" is possibly served by a http server, not a fastcgi server.

> this gets me in the logs.
> 016/07/02 00:51:57 [error] 18120#0: *61 upstream sent unsupported FastCGI protocol version: 72 while reading response header from upstream, client:, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://", host: " localhost"

If you make a bad http request to a http server, it will likely return
something that starts with "HTTP". The decimal value of ascii "H" is
"72"; a fastcgi client may expect the first octet to refer to the fastcgi
protocol version.

So your error message hints that your upstream is not a fastcgi server
but is a http server.

Which in turn suggests that the fix is:

>                          location ~ \.php$ {
>                        # Test for non-existent scripts or throw a 404 error
>                        # Without this line, nginx will blindly send any request ending in .php to php-fpm
>                        try_files $uri =404;
>                         include /etc/nginx/fastcgi.conf;

* delete those two

>                        fastcgi_pass;  ## Make sure the socket corresponds with PHP-FPM conf file

* replace that with


Francis Daly        francis at

More information about the nginx mailing list