title: Permission Denied when attempting to start Daphne systemctl process
body: <p>I'm deploying a website using Django and Django-Channels, with Channel's <code>daphne</code> ASGI server substituting for the typical Gunicorn WSGI setup. Using <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04" rel="nofollow noreferrer">this Gunicorn WSGI tutorial</a> as a jumping off guide, I attempted to write a systemctl service for my daphne server, when I hit the below error:</p>
  
  <p><code>CRITICAL Listen failure: [Errno 13] Permission denied: '27646' -&gt; b'/run/daphne.sock.lock'</code></p>
  
  <p>I was unfortunately unable to find any answers to why permissions would be denied to the <code>.sock</code> file, (in context to Daphne) so I was hoping I could get some hints on where to begin debugging this problem. Below are my <code>daphne.socket</code> and my <code>daphne.service</code> files.</p>
  
  <p><strong>daphne.service</strong></p>
  
  <pre><code>[Unit]
  Description=daphne daemon
  Requires=daphne.socket
  After=network.target
  
  [Service]
  User=brianl
  Group=www-data
  WorkingDirectory=/home/brianl/autoXMD
  ExecStart=/home/brianl/autoXMD/env/bin/daphne -u /run/daphne.sock -b 0.0.0.0 -p 8000 autoXMD.asgi:application
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p><strong>daphne.socket</strong></p>
  
  <pre><code>[Unit]
  Description=daphne socket
  
  [Socket]
  ListenStream=/run/daphne.sock
  
  [Install]
  WantedBy=sockets.target
  </code></pre>
  
  <p>Based off the linked DigitalOcean tutorial, I start my service with <code>sudo systemctl start daphne.socket</code>.</p>
  
  <p>My guess is that there's some kind of discrepancy between setting up systemctl services for Gunicorn and Daphne that I missed, but I don't know for sure. </p>
  
  <p>(If it helps, I'm planning on using Nginx as the main server, but I haven't reached that point yet)</p>
  
  <p>EDIT:</p>
  
  <p>It would help if I also attached the full output systemd gives:</p>
  
  <pre><code>● daphne.service - daphne daemon
     Loaded: loaded (/etc/systemd/system/daphne.service; enabled; vendor preset: enabled)
     Active: failed (Result: start-limit-hit) since Thu 2019-09-05 22:00:43 UTC; 1min 51s ago
    Process: 22041 ExecStart=/home/brianl/autoXMD/env/bin/daphne -u /run/daphne.sock -b 0.0.0.0 -p 8000 autoXMD.asgi:application (code=exited, status=0/SUCCESS)
   Main PID: 22041 (code=exited, status=0/SUCCESS)
  
  Sep 05 22:00:43 autoxmd daphne[22041]:   warnings.warn('%s.  joblib will operate in serial mode' % (e,))
  Sep 05 22:00:43 autoxmd daphne[22041]: 2019-09-05 22:00:43,013 INFO     Starting server at tcp:port=8000:interface=0.0.0.0, unix:/run/daphne.sock
  Sep 05 22:00:43 autoxmd daphne[22041]: 2019-09-05 22:00:43,017 INFO     HTTP/2 support not enabled (install the http2 and tls Twisted extras)
  Sep 05 22:00:43 autoxmd daphne[22041]: 2019-09-05 22:00:43,020 INFO     Configuring endpoint tcp:port=8000:interface=0.0.0.0
  Sep 05 22:00:43 autoxmd daphne[22041]: 2019-09-05 22:00:43,022 INFO     Listening on TCP address 0.0.0.0:8000
  Sep 05 22:00:43 autoxmd daphne[22041]: 2019-09-05 22:00:43,022 INFO     Configuring endpoint unix:/run/daphne.sock
  Sep 05 22:00:43 autoxmd daphne[22041]: 2019-09-05 22:00:43,022 CRITICAL Listen failure: [Errno 13] Permission denied: '22041' -&gt; b'/run/daphne.sock.lock'
  Sep 05 22:00:43 autoxmd systemd[1]: daphne.service: Start request repeated too quickly.
  Sep 05 22:00:43 autoxmd systemd[1]: daphne.service: Failed with result 'start-limit-hit'.
  Sep 05 22:00:43 autoxmd systemd[1]: Failed to start daphne daemon.
  </code></pre>