简体   繁体   中英

Django 502 bad gateway with Nginx and Uwsgi

I can normally open up my web in the front several hours after deployment,but later , it occurred 502 bad gateway ,it is so wired, my web uses Django and Nginx and Uwsgi, i do research a lot on google,but failed with nothing

Here is my configuration:

1.Nginx configuration

# mysite_nginx.conf


upstream django {


server 127.0.0.1:8004; # for a web port socket (we'll use this first)
}


server {

listen      80;

server_name www.example.com  # substitute your machine's IP address or FQDN
charset     utf-8;


client_max_body_size 75M;   # adjust to taste


location /media  {
    alias /home/blender_font_project/django_file/Blender_website/media;  
}

location /static {
    alias /home/blender_font_project/django_file/Blender_website/static; 
}



location / {


    uwsgi_pass 127.0.0.1:8003;
    include     /etc/nginx/uwsgi_params; 
}
}

2.uwsgi configuration

# mysite_uwsgi.ini file
[uwsgi]

chdir           = /home/blender_font_project/django_file/Blender_website

module          = djangoTest5.wsgi

master          = true

processes       = 10

socket          = :8003

vacuum          = true
harakiri=60
daemonize=/home/blender_font_project/uwsgi_file/real3dfont_logfile

3.this is my Nginx error log

231 connect() failed (111: Connection refused) while connecting to upstream

BTW , i have set Django to DEBUG Ture and i can access my resource by www.example.com/static/example.jpg ,but the web page shows 502

I really dont know why , thanks if you offer any help!

(...After million years struggle and strive,with inspiration from a super hero in comment named @Atul Mishra , i finally figure it out...)

It is the matter Django itself,i forget to download mysql module in View , i would have expect a Django error html if it is the django problem, but no , so i mistakenly attribute it to Nginx or Uwsgi

But the wired thing is that Django should have report the error , but no ! what an irresponsible dude!!

so , 1.remember to add Django error log function ,it saves your life , and

2.test Django with runserver before Nginx enter the stage even when comet is striking the earth!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM