title: gunicorn daemon (active: failed) / curl(56) Recv Failure: Connection reset by peer
body: <p>First thing, I am not sure if this is better here or on ask ubuntu (ubuntu did not have a 'gunicorn' tag so I think i'm in the right place). If it is not appropriate here just drop it in the comments and I'll close it.</p>
  
  <p>I am following a digitalocean tutorial on deployment(<a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04).I" rel="nofollow noreferrer">https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04).I</a> am up to gunicorn set up. I'm at my wits end trying to get this gunicorn to work, so I have come here. Anything in quotes is the name of the current section in the article. I got up to "Checking for the Gunicorn Socket File" and "check for the existence of the <code>gunicorn.sock</code> file within the /run directory:" before failure. 
  Check for socket file:</p>
  
  <pre><code>  sudo systemctl status gunicorn.socket returns
      Failed to dump process list, ignoring: No such file or directory
      ● gunicorn.socket - gunicorn socket
         Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor pres
         Active: active (listening) since Fri 2020-02-21 21:34:06 UTC; 1min 8s ago
         Listen: /run/gunicorn.sock (Stream)
         CGroup: /system.slice/gunicorn.socket
  </code></pre>
  
  <p>Check for existence of <code>gunicorn.sock</code>:</p>
  
  <pre><code>file /run/gunicorn.sock
  </code></pre>
  
  <p>output: <code>/run/gunicorn.sock: socket</code></p>
  
  <p>Upon "Testing socket activation", it fails:</p>
  
  <pre><code>sudo systemctl status gunicorn
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>● gunicorn.service - gunicorn daemon
     Loaded: loaded (/etc/systemd/system/gunicorn.service;
     Active: failed (Result: exit-code) since Fri 2020-02-
   Main PID: 15708 (code=exited, status=217/USER)
  
  Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: S
  Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[15708
  Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[15708
  Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: g
  Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: g
  Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: g
  Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: g
  Feb 21 21:32:39 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: F
  lines 1-13/13 (END)
  </code></pre>
  
  <p>It says to test socket activation, do the following:</p>
  
  <pre><code>curl --unix-socket /run/gunicorn.sock localhost
  </code></pre>
  
  <p>output(says I should see HTML): </p>
  
  <pre><code>curl: (56) Recv failure: Connection reset by peer
  </code></pre>
  
  <p>Not sure if I provided enough info. Below I will include my <code>gunicorn.socket</code> and <code>gunicorn.service</code> files as well as the layout of directories on my server.</p>
  
  <p>gunicorn.socket:</p>
  
  <pre><code>[Unit]
  Description=gunicorn socket
  
  [Socket]
  ListenStream=/run/gunicorn.sock
  
  [Install]
  WantedBy=sockets.target
  </code></pre>
  
  <p>gunicorn.service:</p>
  
  <pre><code>[Unit]
  Description=gunicorn daemon
  Requires=gunicorn.socket
  After=network.target
  
  [Service]
  User=justin
  Group=www-data
  WorkingDirectory=/home/justin/project
  ExecStart=/home/justin/project/env/bin/gunicorn \
            --access-logfile - \
            --workers 3 \
            --bind unix:/run/gunicorn.sock \
            jobzumo.wsgi:application
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>Layout of server/project:</p>
  
  <pre><code>home/justin/project/
  </code></pre>
  
  <p>This <code>project/</code> folder contains <code>env</code>(<code>env/bin/gunicorn</code> does exist), <code>jobzumo</code>(django project), <code>manage.py</code> and <code>static</code>.</p>
  
  <p>The only thing I am thinking is that I may have created these gunicorn files while using <code>root</code> and now I am trying to modify them using the user <code>justin</code>? Not really sure what is going on here. If I did not provide enough info or if you need me to run any type of debug commands please let me know. Thanks for any help.</p>