0

I want to deploy my django project with Ubuntu and Digital Ocean. It's not the first time I do it but now I keep getting this error and I don't know what's causing it. I used this video as guide for the process: https://www.youtube.com/watch?v=US9BkvzuIxw. It's really annoying because the only message that I get is "502 Bad Gateway nginx/1.18.0 (Ubuntu)" and what I found on internet to solve it doesn't work. All nginx tests I run say it works correctly. This is the code where I think the error must be:

/etc/nginx/sites-available/locallibrary

server {
        server_name vvmwp.nl;

        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
                root /home/sammy/locallibrary;
        }

        location / {
                include proxy_params;
                proxy_pass http://unix:/run/gunicorn.sock;
        }
}

/etc/systemd/system/gunicorn.service

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

[Service]
User=sammy
Group=sammy
EnvironmentFile=/home/sammy/locallibrary/env
WorkingDirectory=/home/sammy/locallibrary
ExecStart=/home/sammy/env/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          locallibrary.wsgi:application

[Install]
WantedBy=multi-user.target

/etc/systemd/system/gunicorn.socket

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

Thanks in advance

Enmanuel V
  • 31
  • 1
  • 5
  • Replace the name sammy with your own username (unless it happens to be sammy :) in your nginx and gunicorn files. You may have to reload the service, `sudo systemctl daemon-reload`. Best of luck! – raphael Mar 24 '22 at 22:29
  • My username is sammy and I already ran all the reloads and restarts for nginx. I think the error must be anywhere else. Thanks anyway – Enmanuel V Mar 25 '22 at 07:08

1 Answers1

0

I faced the same issue and nothing worked but then I killed the previous port in my case was 8080 and installed nginx and pm2 again and everything worked fine.

codeVibek
  • 106
  • 1
  • 7