Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

338
Vistas
Publish Django project with gunicorn and NGINX

Im trying to publish my Django project with NGINX and gunicorn, but I get permission denied from gunicorn.

My last steps what I did.

mkdir /home/sama/websites
cd /home/sama/websites
mkdir test_project
cd test_project

create Virtualenvirement for this project virtualenv --python=/usr/bin/python3.8 venv

Virtualenvirement activate source venv/bin/activate

Gunicorn & Django install

pip3 install gunicorn
pip3 install django

create project

cd ..
django-admin startproject config test_project

allow firewall to port 8000 sudo ufw allow 8000

run first test python manage.py runserver 0.0.0.0:8000

open my server ip on webbrowser myIP:8000 I can see Django basic page

stop server CTRL + C

testGunicorn gunicorn --bind 0.0.0.0:8000 config.wsgi

testagain on webbrowser Again I can see Djangos page

Server stop CTRL + C

exit virtualenvirement deactivate

config Gunicorn create 2 files in /etc/systemd/system/

gunicorn.socket and gunicorn.service

edit this files sudo nano /etc/systemd/system/gunicorn_test_project.socket

/etc/systemd/system/gunicorn.socket
[Unit]
Description=gunicorn daemon

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target
/etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=sama
Group=www-data
WorkingDirectory=/home/sama/websites/test_project
ExecStart=/home/sama/websites/test_project/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock config.wsgi:application

[Install]
WantedBy=multi-user.target

test socket

sudo systemctl start gunicorn.socket
sudo systemctl enable gunicorn.socket

systemlink created, check it file /run/gunicorn.sock Output: /run/gunicorn.sock: socket

curl --unix-socket /run/gunicorn.sock localhost

And now I get permission denied

I already set permission for the folder test_project to user sama and group www-data, but without any effects. What is wrong?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I see no good reason to use systemd socket activation here.

Just use a service file and have Gunicorn bind to HTTP.

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

[Service]
User=sama
Group=www-data
WorkingDirectory=/home/sama/websites/test_project
ExecStart=/home/sama/websites/test_project/venv/bin/gunicorn --access-logfile - --workers 3 --bind 0.0.0.0:8000 config.wsgi:application

[Install]
WantedBy=multi-user.target
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda