title: uwsgi: connection refused when running from startup script
body: <p>I want to run a django site on amazon ec2 (ubuntu) with nginx and uwsgi. I have followed a basic setup as described <a href="http://posterous.adambard.com/start-to-finish-serving-mysql-backed-django-w" rel="nofollow">here</a>. </p>
  
  <p>When I start uwsgi from the command line (as ubuntu user), everything works fine, the site is served up properly:</p>
  
  <pre><code>/home/ubuntu/uwsgi-1.3/uwsgi --home /home/ubuntu/apps/mysite-env/site/ --socket /tmp/uwsgi_mysite.sock --chmod-socket --module mysite_wsgi --pythonpath /home/ubuntu/apps/mysite-env/site/mysite/production -H /home/ubuntu/apps/mysite-env
  </code></pre>
  
  <p>However when I want to demonize this via a startup script, uwsgi reports the following error:</p>
  
  <pre><code>2012/11/06 12:50:08 [error] 1773#0: *10 connect() to unix:///tmp/uwsgi_mysite.sock failed (111: Connection refused) while connecting to upstream, client: 91.66.145.99, server: *.mysite.com, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi_mysite.sock:", host: "mysite.com"
  </code></pre>
  
  <p>(this looks like a permissions issue)</p>
  
  <p>my startup script looks like this</p>
  
  <pre><code># file: /etc/init/uwsgi_mysite.conf 
  description "uWSGI server"
  
  start on runlevel [2345]
  stop on runlevel [!2345]
  
  respawn
  exec /home/ubuntu/uwsgi-1.3/uwsgi --home /home/ubuntu/apps/mysite-env/site/ --socket /tmp/uwsgi_mysite.sock --chmod-socket 777 --module mysite_wsgi --pythonpath /home/ubuntu/apps/mysite-env/site/mysite/production -H /home/ubuntu/apps/mysite-env
  </code></pre>
  
  <p>I have tried to execute the startup command as ubuntu user
  <code>exec sudo -u ubuntu "command...</code>"
  but to no avail.</p>
  
  <p>I also tried to change permissions for the socket file by passing in </p>
  
  <pre><code>--chmod-socket 777
  </code></pre>
  
  <p>but no luck here either. I'm out of ideas as to how to fix this, any input is appreciated!</p>