title: PM2 and Nginx: 502 Bad Gateway
body: <p>I've been trying to deploy my Node project on a brand new DO droplet, but i'm having some problems with PM2.</p>
  
  <p>My steps are a follows:</p>
  
  <ol>
  <li>Node came installed on the Droplet image (Ubuntu, Node v4.4.4)</li>
  <li>Installed PM2 globally</li>
  <li>Setup Nginx to reverse proxy 127.0.0.1:3000</li>
  <li>Cloned my project and did npm install</li>
  </ol>
  
  <p>All i get is Nginx complaining about a 502 Bad Gateway.</p>
  
  <p>If i look at the Nginx error.log i get this:</p>
  
  <blockquote>
    <p>connect() failed (111: Connection refused) while connecting to
    upstream, client: <strong><em>client.ip</em></strong>, server: <strong><em>my.server</em></strong>, request:
    "GET / HTTP/1.1", upstream: "<a href="http://127.0.0.1:3000/" rel="noreferrer">http://127.0.0.1:3000/</a>", host:
    "<strong><em>my.server</em></strong>"</p>
  </blockquote>
  
  <p>PM2 doesn't have much to say about anything. Nothing in <em>pm2 logs</em> and status is <strong>online</strong>.</p>
  
  <p>I tried skipping PM2 and just doing npm start which worked perfectly. I also tried setting up a dummy hello world application instead, and using that with PM2 - it also worked.</p>
  
  <p>So this is currently where i'm at:</p>
  
  <ul>
  <li>My project + PM2: doesn't work.</li>
  <li>My project without PM2: works.</li>
  <li>Hello World app + PM2: works.</li>
  </ul>
  
  <p>I'm not really sure where to go from here.. I could just skip PM2 and use node, but i do want the features of PM2.</p>
  
  <p>Any ideas?</p>