Question

502 error on django application after server reboot

this is my gunicorn.service file.

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myprojectdir
ExecStart=/var/www/html/new_remove_bg/newvenv/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          /var/www/html/new_remove_bg/mysite/mysite.wsgi:application

[Install]
WantedBy=multi-user.target




ExecStart=/var/www/html/new_remove_bg/newvenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/var/www/html/new_remove_bg/mysite/mysite.sock myproject.wsgi:application

this is my new_remove_bg file

server {
    listen 80;
    server_name slicebg.com;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /var/www/html/new_remove_bg/mysite;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/var/www/html/new_remove_bg/mysite/mysite.sock;
    }
}

Please guide me how to overcome this issue and i am trying to deploy django application.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I did not, I just used the above commands which you mentioned, after that I faced this error.

Hi there,

You would see a 502 error when the backend service is not running.

Is the Gunicorn service running? You can check that with this command:

sudo systemctl status gunicorn

If it is not running make sure that it is started:

sudo systemctl start gunicorn

Also you can enable the service, so that the next time the server reboots, it would start automatically:

sudo systemctl enable gunicorn

Let me know how it goes. Regards, Bobby