Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have installed and configured PHP-FPM, Nginx, and then phpMyAdmin. When I access the main site everything works fine but as soon as I go to I get a 502 bad gateway error.

When I look in my error logs I see the following error repeated throughout: (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx

Here is my default.conf for nginx:

I have tried many different configurations that I have found from users that have had the same issue but can't seem to get any of them to work.

share|improve this question
up vote 4 down vote accepted

I found under step 7 that you have to change the reference of the fastcgi_pass to your unix socket (ex: /tmp/php5-fpm.sock) instead of it listening to

This has been a great learning experience, since I don't know the innards of Ubuntu/Unix

share|improve this answer

Change the fastcgi_pass line (line 52 in your example) to:

fastcgi_pass unix:/var/run/php5-fpm.sock;

This is valid for Ubuntu 12.10

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.