4

I am creating a django application using nginx as my server with uwsgi. However when i entered my domain or ip address to access my site. I got an 502 BAD GATEWAY ERROR. So I decided to look at my logs to see if i made a mistake because I was following Digital Ocean tutorial.

https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-16-04

Nginx file

server {
listen 80;
server_name 173.212.203.105;
error_log /root/logs/error.log;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
    root /root/muzillasite;
}

location / {
    include         uwsgi_params;
    uwsgi_pass      unix:/run/uwsgi/muzillasite.sock;
}

}

Uwsgi ini

[uwsgi]
project = muzillasite
base = /root

chdir = %(base)/%(project)
home = %(base)/%(project)

module = %(project).wsgi:application

master = true
processes = 5

socket = %(base)/%(project)/%(project).sock
chmod-socket = 664
vacuum = true

Uwsgi conf

description "uWSGI application server in Emperor mode"

start on runlevel [2345]
stop on runlevel [!2345]

setuid root
setgid www-data

exec /usr/local/bin/uwsgi --emperor /etc/uwsgi/sites

Errors

uwsgi.service - uWSGI Emperor service
   Loaded: loaded (/etc/systemd/system/uwsgi.service; enabled; vendor preset: enabled)
   Active: failed (Result: start-limit-hit) since Sun 2017-01-15 22:57:00 CET; 2s ago
  Process: 1127 ExecStart=/usr/local/bin/uwsgi --emperor /etc/uwsgi/sites (code=exited, status=203/EXEC)
  Process: 1122 ExecStartPre=/bin/bash -c mkdir -p /run/uwsgi; chown root:www-data /run/uwsgi (code=exited, status=0/SUCCESS)
 Main PID: 1127 (code=exited, status=203/EXEC)

Error Logs

2017/01/15 21:58:51 [crit] 28840#28840: *34 connect() to unix:/run/uwsgi/muzillasite.sock failed (2: No such file or directory) while
Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
Young Kuffey
  • 41
  • 1
  • 2
  • This won't help you, but I had a similar looking issue where the problem was I was using `--daemonize` - `systemd` and that argument don't get along. Switch to using `--logto` instead if you want to control where logs are going, or remove the argument entirely if you just want it running in the background - that's what making it a `systemd` service does anyways. – ArtOfWarfare Oct 15 '20 at 23:25

0 Answers0