Server Fault is a question and answer site for system and network administrators. 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 am trying to add a module to an existing Django project, but once I have done it I get a 502 error. The server is running Ubuntu. I don't think it has to do with the applications code because I got it running on the django development server. It goes away when I take out the app's name from and restart gunicorn.

Here's a part of the log

2011/07/15 01:24:45 [error] 16136#0: *75593 connect() failed (111: Connection refused)   while connecting to upstream, client:, server:, request: "GET / HTTP/1.1", upstream: "", host: ""

Here's the nginx config file. Nginx Config File

I'm not sure what other information is needed. Not sure where the gunicorn logs are located. My server admin skills are kind of lacking. What sort of things should I be doing to figure out where the problem is starting.

share|improve this question
Did you try changing your dir permission? it worked for me. – Aswin Nov 7 '15 at 11:18

Probably there is an error in the module which causing django application to fail completely. Check if it is running at all.

share|improve this answer
I'm not used to much server admin. How would I check if it is running? – thebeagle Jul 15 '11 at 18:57

How did you install the new module? If you installed it on your dev machine using pip, apt-get, etc., make sure you do the same on your server.

share|improve this answer

I don't know if this will apply to you, but I had a similar issue using nginx and passenger, and I wasn't including my django root directory (the one with in my work path. I've not worked with gunicorn, but is it possible you need to add sys.path.append on that directory somewhere in your gunicorn configuration?

share|improve this answer

Connection refused is a pretty obvious one. It means your backend (in this case, gunicorn) is not running on the port you've specified in your nginx config (in this case, 8020).

One of two things is going on here. Either:

  1. gunicorn is running on a different port, or
  2. gunicorn is not running.

If you're sure this is the right port, then try starting gunicorn.

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.