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 settings.py.

However, when I run Django's test server (python manage.py 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.

  • 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 passenger_wsgi.py 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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