I saw your post yesterday, just searching for an answer for exactly the same issue. Finally, today I reached the root of the problem.
I suppose you specify the chdir in your .ini config file as the directory where your project is located. I mean that if for example your project is 'myproject' and you have it in '/var/www/myproject' directory, you specify '/var/www' as the chdir.
So, the path for all internal resources is not well defined, and Python interpereter (may be you are using Django?) does not reach them. Ok, I will explain how a solution works in a Django project. For example, suppose that you have an app inside your project called 'app1'; in your views module you are calling for a forms defined in your forms module; you will be doing this like that:
from app1.forms import *
okay? Well, the thing is that the path is not well defined for uwsgi. You should now define this like that:
from myproject.app.forms import *
and you will see that everything is working now. No more 502 Bad Gateway errors will appear for you :)
Yes, I know that is not very elegant to add 'myproject.' to every internal resource calling. So, you can simply add this to your 'settings.py' file:
sys.path.append('/var/www/myproject/')
Substitute '/var/www/' for the path where your project is located on your machine. With this tiny solution, every started working for me :)
I hope my comment helps you.
Cheers,
Jose
I detected where (yet not what) was causing the error: a template module in the CMS extensions that is not working properly. Disabling the module made the error go away.
Anyway, thanks for your opinions and efforts!
Best Answer
This error usually indicates that your Django application has crashed (raised an unhandled exception). You should be able to get more information from the uwsgi logs at
/var/log/uwsgi
.