March 13, 2017

NGINX 520 bad gateway and error 111 in the error log

By Geekphreek

To any newbies with setting up NGINX it can be a dull and painful experience, or an enjoyable one if you’re that way inclined.

Installing on Debian is simple but there’s a little trick you MUST remember to do: If you are getting “520 bad gateway” and in your error log getting “2017/03/13 00:01:02 [error] 10441#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client:, server:, request: “GET / HTTP/1.1”, upstream: “fastcgi://”, host: “”” go to edit this file: /etc/php5/fpm/pool.d/www.conf and add:

listen.allowed_clients =

Just add it on the bottom. Save and quit out and then do:

service php5-fpm restart
service nginx restart

You should now find your site loads fine.