title: gunicorn does not start after boot
body: <p>I'm running a Debian web server with nginx and gunicorn running a django app. I've got everything up and running just fine but after rebooting the server I get a 502 bad gateway error. I've traced the issue back to gunicorn being inactive after the reboot. If I start the service the problem is fixed until I reboot the server again.</p>
  
  <p>Starting the service:</p>
  
  <pre><code>systemctl start gunicorn.service
  </code></pre>
  
  <p>After the reboot here is my gunicorn service status:</p>
  
  <pre><code>{username}@instance-3:~$ sudo systemctl status gunicorn
  ● gunicorn.service - gunicorn daemon
  Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled)
  Active: inactive (dead)
  </code></pre>
  
  <p>Contents of my /etc/systemd/system/gunicorn.service file:</p>
  
  <pre><code>[Unit]
  Description=gunicorn daemon
  After=network.target
  
  [Service]
  User={username}
  Group={username}
  WorkingDirectory=/home/{username}/web/{projname}
  ExecStart=/usr/local/bin/gunicorn {projname}.wsgi:application
  Restart=on-failure
  
  [Install]
  WantedBy=multi.user.target
  </code></pre>
  
  <p>Any ideas to figure out why the gunicorn service isn't starting after reboot?</p>
  
  <p>Edit: </p>
  
  <p>Could the issue be that the gunicorn.conf has a different dir in chdir and the exec than the working directory?</p>
  
  <pre><code>{username}@instance-3:~$ cat /etc/init/gunicorn.conf 
  cription "Gunicorn application server handling {projname}"
  
  start on runlevel [2345]
  stop on runlevel [!2345]
  
  respawn
  setuid {username}
  setgid {username}
  chdir /home/data-reporting/draco_reporting
  
  exec {projname}/bin/gunicorn --workers 3 --bind unix:/home/{username}/data-reporting/{projname}/{projname}.sock {projname}.wsgi:application
  </code></pre>