I am attempting to set up a website right now with gunicorn and am receiving a 502 error. When I check my error logs, I see the following:
2024/04/17 03:46:28 [crit] 13153#13153: *3 connect() to unix:/home/jimmy/portfolio/peak.sock failed (2: No such file or directory) while connecting to upstream, client: 216.165.95.139, server: website, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/home/jimmy/portfolio/peak.sock:/favicon.ico", host: "website", referrer: "https://website/"
As mentioned in the title, peak.sock is not being created.My permissions are set to the following:
drwxrwxr-x 2 jimmy jimmy 4096 Apr 17 02:21 __pycache__-rw-rw-r-- 1 jimmy jimmy 0 Apr 17 00:54 codedrwxrwxr-x 3 jimmy jimmy 4096 Apr 17 01:22 envdrwxr-xr-x 5 jimmy www-data 4096 Apr 17 03:22 portfoliodrwx------ 3 jimmy jimmy 4096 Apr 17 00:51 snapdrwxrwxr-x 2 jimmy www-data 4096 Apr 17 02:50 __pycache__-rw-rw-r-- 1 jimmy www-data 341 Apr 17 02:36 peak.pydrwxrwxr-x 2 jimmy www-data 4096 Apr 17 01:22 templates-rw-rw-r-- 1 jimmy www-data 1675 Apr 17 01:22 'udo journalctl -u peak.service'-rw-rw-r-- 1 jimmy www-data 64 Apr 17 02:49 wsgi.py
/etc/systemd/system/peak.service is the following:
[Unit]Description=Gunicorn instance to serve peak Flask appAfter=network.target[Service]User=jimmyGroup=www-dataWorkingDirectory=/home/jimmy/portfolioEnvironment="PATH=/home/jimmy/portfolio/env/teton/bin:$PATH"ExecStart=/home/jimmy/portfolio/env/teton/bin/gunicorn --workers 3 --bind unix:/home/jimmy/portfolio/peak.sock -m 007 wsgi:app[Install]WantedBy=multi-user.target
/etc/nginx/sites-available/peak.conf is set to the following:
server{ server_name jimmychen.xyz www.jimmychen.xyz; location / { include proxy_params; proxy_pass http://unix:/home/jimmy/portfolio/peak.sock; } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/jimmychen.xyz/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/jimmychen.xyz/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot}server{ if ($host = www.jimmychen.xyz) { return 301 https://$host$request_uri; } # managed by Certbot if ($host = jimmychen.xyz) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; server_name jimmychen.xyz www.jimmychen.xyz; return 404; # managed by Certbot}
Interestingly enough, I can use
gunicorn --bind 0.0.0.0:5000 wsgi:app
but
sudo systemctl start gunicorn
yields
Failed to start gunicorn.service: Unit gunicorn.service not found.
I'm at my wits end here, any help would be appreciated. Thank you!
I have tried creating a gunicorn.service file of my own in /etc/systemd/system/gunicorn.socket
[Unit]Description=gunicorn socket[Socket]ListenStream=/run/gunicorn.sock[Install]WantedBy=sockets.target~