Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

615
Visualizações
Django + Nginx + Gunicorn setup with error: (104: Connection reset by peer) while reading response header from upstream

I have a server set up with Ubuntu 20.04, Nginx and running a Django app with Gunicorn. My gunicorn.socket file is like so:

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

And My gunicorn.service file is so:

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

[Service]
User=root
Group=www-data
WorkingDirectory=/root/backend
ExecStart=/root/.local/share/virtualenvs/backend-Lu9kB6KY/bin/gunicorn \
        --access-logfile /var/log/nginx/backend.log \
        --workers 3 \
        --bind unix:/run/gunicorn.sock \
        backend.wsgi:application

[Install]
WantedBy=multi-user.target

And in a file at /etc/nginx/sites-available/backend, I have:

server {
        listen 80;
        listen [::]:80;

        server_name domain.com;

        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
                root /root/backend/;
        }

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

When I visit the homepage, I see a 502 Bad Gateway error, and the logs at /var/log/nginx/error.log shows: [error] 15866#15866: *86 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 82.102.24.9, server: domain.com, request: "GET / HTTP/1.1", upstream: "http://unix:/run/gunicorn.sock:/", host: "domain.com"

What have I done wrong? What to do?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda