Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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've configured a Debian 6 server with nginx, Passenger, and MySQL to run Django, and was running through the Django tutorial with everything going swimmingly until I tried to turn on the admin interface.

Now it returns a 502 bad gateway whenever I have admin.autodiscover() on and any user-created app included in INSTALLED_APPS under

However, when I run Django's test server (python runserver), everything works fine, I can get into and use the admin interface, and everything's great, so it appears the problem is in the server configs, not the app code I've written (which isn't surprising, as it's verbatim from Django's tutorial).

Would love to solve this.

share|improve this question
The error log readout is: 2012/01/16 14:09:58 [error] 22715#0: *1 upstream prematurely closed connection while reading response header from upstream, client: [IP_ADDRESS], server: [HOSTNAME], request: "GET /admin/ HTTP/1.1", upstream: "passenger:unix:/passenger_helper_server:", host: "[HOSTNAME]" – futuraprime Jan 16 '12 at 20:10

After much wrangling and gnashing of teeth, I've tracked this error down. My was not loading in the environment correctly, so django wasn't able to find my apps to import. Once I had made sure that I was running sys.path.append on both my passenger root and my django root, everything worked properly.

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.