title: Node (keystonejs) address already in use error, but is not. Also EACCES error. NGINX behind
body: <p>Project has <a href="http://keystonejs.com" rel="nofollow noreferrer">keystonejs</a> which is a Nodejs CMS.</p>
  <p>Suddenly (well, probably after try to install SSL certificates, stop and start again the node server and nginx) it stops working.</p>
  <p>When I try <code>node keystone.js</code> with my no-root user I have this error:</p>
  <pre><code>Error: listen EACCES
  at errnoException (net.js:901:11)
  at Server._listen2 (net.js:1020:19)
  at listen (net.js:1061:10)
  at net.js:1143:9
  at dns.js:72:18
  at process._tickCallback (node.js:415:13)
  </code></pre>
  <p>This error appears when you try to <a href="https://stackoverflow.com/questions/9164915/node-js-eacces-error-when-listening-on-most-ports">start node on a port &lt; 1024</a> but is not the case because I have it on port 3000.</p>
  <p>When I try <code>node keystone.js</code> as root the error is:</p>
  <blockquote>
  <p>my-project failed to start: address already in use</p>
  <p>Please check you are not already running a server on the specified port.</p>
  </blockquote>
  <p>I found that error string in keystone files as <code>EADDRINUSE</code></p>
  <p>With <code>netstat -lntu</code> I cheked <a href="https://superuser.com/questions/529830/get-a-list-of-open-ports-in-linux">which ports are in use</a> but <code>:3000</code> is not.</p>
  <p>Checked too if port is open:</p>
  <pre><code>root@localhost:/home# sudo ufw status | grep 3000
  3000                       ALLOW       Anywhere
  3000 (v6)                  ALLOW       Anywhere (v6)
  </code></pre>
  <p>I typed <code>ps aux | grep node</code> to check if there is a node/nodemon/forever task running on the server. There is only one node running that is not related with this project.</p>
  <pre><code>root@localhost:/home# ps aux | grep node
  server   30637  0.0  0.3 673840 25588 ?        Ssl  11:15   0:00 /usr/bin/nodejs /usr/lib/node_modules/forever/bin/monitor keystone.js
  server   30639  0.1  1.9 994280 156736 ?       Sl   11:15   0:06 /usr/bin/nodejs /home/server/my-other-project/keystone.js
  root     31503  0.0  0.0  11716   932 pts/1    S+   12:28   0:00 grep --color=auto node
  </code></pre>
  <p>Finally I thought <code>EADDRINUSE</code> error may be related with the port of <code>nginx</code> that is behind the server (I redirect port <code>80</code> to <code>3000</code>) I check if something is blocking that port:</p>
  <pre><code>root@localhost:/home/# netstat -tulpn | grep :80
  tcp        0      0 0.0.0.0:80              0.0.0.0:*                 LISTEN      31266/nginx     
  tcp6       0      0 :::80                   :::*                    LISTEN      31266/nginx  
  </code></pre>
  <p><strong>Do you have any idea why this happens?</strong></p>