title: Passenger, Plesk and Node.js: address already in use
body: <p>My question is about getting Phusion Passenger and Plesk Onyx 17.5.3 to work together nicely. I have a new server running Ubuntu 16.04.</p>
  
  <p>I am following the official <a href="https://github.com/phusion/passenger/wiki/Phusion-Passenger%3A-Node.js-tutorialC" rel="nofollow noreferrer">Phusion Passenger tutorial</a> on deploying a Node.js app, and I have followed it successfully to the point where I need to <a href="https://github.com/phusion/passenger/wiki/Phusion-Passenger%3A-Node.js-tutorial#deploying-standalone" rel="nofollow noreferrer">tell Passenger to listen on port 80</a>.</p>
  
  <p>Here are my steps:</p>
  
  <ul>
  <li>With my registrar, I set up a DNS entry for the subdomain <code>pass.domain.com</code></li>
  <li>In the Plesk interface, I define the new subdomain</li>
  <li>If I visit <code>http://pass.domain.com</code> in my browser, I get the default Plesk web page.</li>
  <li>I follow the "Phusion Passenger: Node.js tutorial" until I <a href="https://github.com/phusion/passenger/wiki/Phusion-Passenger%3A-Node.js-tutorial#deploying-standalone" rel="nofollow noreferrer">reach this command</a>:</li>
  </ul>
  
  <p><code>sudo passenger start --port 80 --user someusername --environment production --daemonize
  </code></p>
  
  <ul>
  <li>Note: I am using a valid custom user name in the place of `someusername'.</li>
  <li>I get this error:</li>
  </ul>
  
  <blockquote>
  <pre><code>Could not start the Nginx engine:  
  nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)  
  nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)  
  nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)  
  nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)  
  nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)  
  nginx: [emerg] still could not bind()
  </code></pre>
  </blockquote>
  
  <p>It appears that Plesk is already serving the default web page at this address, so Phusion Passenger cannot access it. What files do I need to add or edit to get Plesk to release the address so that Passenger can use it?</p>
  
  <p>EDIT 4: I have found <a href="https://stackoverflow.com/questions/29524067/nginx-on-ubuntu-giving-address-already-in-use-error?rq=1">this question</a> which describes similar symptoms. However the OP is using Meteor Up and I am using Passenger. His solution was to get Meteor Up to tell Node.js to run on port 3001, and get nginx to listen on port 80 and proxy requests to port 3001. I had understood that Phusion Passenger already does something similar under the hood.</p>
  
  <p>Is there a way to modify the <code>passenger start</code> command to clarify this?</p>
  
  <hr>
  
  <p>OLDER EDITS</p>
  
  <hr>
  
  <p>EDIT 1: In response to @TarunLalwali, here is the output of <code>sudo netstat -plnat</code> on this server:</p>
  
  <pre><code>$ sudo netstat -plnat
  Active Internet connections (servers and established)
  Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
  tcp        0      0 0.0.0.0:4190            0.0.0.0:*               LISTEN      15234/dovecot   
  tcp        0      0 127.0.0.1:12768         0.0.0.0:*               LISTEN      15654/psa-pc-remote
  tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN      15234/dovecot   
  tcp        0      0 0.0.0.0:995             0.0.0.0:*               LISTEN      15234/dovecot   
  tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      2293/mongod     
  tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN      15234/dovecot   
  tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN      15234/dovecot   
  tcp        0      0 127.0.0.1:783           0.0.0.0:*               LISTEN      1315/.spamassassin
  tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      26659/nginx     
  tcp        0      0 0.0.0.0:8880            0.0.0.0:*               LISTEN      23894/config    
  tcp        0      0 0.0.0.0:465             0.0.0.0:*               LISTEN      2142/master     
  tcp        0      0 172.17.0.1:53           0.0.0.0:*               LISTEN      17312/named     
  tcp        0      0 94.76.206.212:53        0.0.0.0:*               LISTEN      17312/named     
  tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      17312/named     
  tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1413/sshd       
  tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      12563/passenger-sta
  tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN      17312/named     
  tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      2142/master     
  tcp        0      0 94.76.206.212:443       0.0.0.0:*               LISTEN      26659/nginx     
  tcp        0      0 0.0.0.0:8443            0.0.0.0:*               LISTEN      23894/config    
  tcp        0      0 94.76.206.212:993       92.130.47.95:49994      ESTABLISHED 15322/imap-login
  tcp        0      0 127.0.0.1:51168         127.0.0.1:12768         TIME_WAIT   -               
  tcp        0      0 94.76.206.212:25        200.188.141.75:51400    TIME_WAIT   -               
  tcp        0    188 94.76.206.212:22        92.130.47.95:34414      ESTABLISHED 4035/sshd: blacksla
  tcp6       0      0 :::4190                 :::*                    LISTEN      15234/dovecot   
  tcp6       0      0 :::993                  :::*                    LISTEN      15234/dovecot   
  tcp6       0      0 :::995                  :::*                    LISTEN      15234/dovecot   
  tcp6       0      0 :::7080                 :::*                    LISTEN      26432/apache2   
  tcp6       0      0 :::7081                 :::*                    LISTEN      26432/apache2   
  tcp6       0      0 127.0.0.1:3306          :::*                    LISTEN      10040/mysqld    
  tcp6       0      0 :::106                  :::*                    LISTEN      1532/xinetd     
  tcp6       0      0 :::110                  :::*                    LISTEN      15234/dovecot   
  tcp6       0      0 :::143                  :::*                    LISTEN      15234/dovecot   
  tcp6       0      0 ::1:783                 :::*                    LISTEN      1315/.spamassassin
  tcp6       0      0 2a02:af8:1:900::3860:80 :::*                    LISTEN      26659/nginx     
  tcp6       0      0 :::8880                 :::*                    LISTEN      23894/config    
  tcp6       0      0 :::465                  :::*                    LISTEN      2142/master     
  tcp6       0      0 :::53                   :::*                    LISTEN      17312/named     
  tcp6       0      0 :::21                   :::*                    LISTEN      1532/xinetd     
  tcp6       0      0 :::22                   :::*                    LISTEN      1413/sshd       
  tcp6       0      0 :::25                   :::*                    LISTEN      2142/master     
  tcp6       0      0 2a02:af8:1:900::386:443 :::*                    LISTEN      26659/nginx     
  tcp6       0      0 :::8443                 :::*                    LISTEN      23894/config 
  </code></pre>
  
  <p>Note: I have already asked about this issue on the <a href="https://talk.plesk.com/threads/passenger-and-node-js-address-0-0-0-0-80-already-in-use.345682/" rel="nofollow noreferrer">Plesk forum</a>, but it has received no response. I am hoping that asking the Phusion Passenger community here will be more productive. Once I have a working solution, I will post a link from the Plesk forum to the answer here.</p>
  
  <p>Thanks in advance for your insights,</p>
  
  <p>James</p>
  
  <hr>
  
  <p>EDIT 2: Following @TarunLalwali's advice, I tried stopping nginx, but this produced an unknown error:</p>
  
  <pre><code>$ sudo nginx -s stop
  $ sudo passenger start --port 80 --user node --environment production --daemonize
  Could not start the Nginx engine:
  nginx: [alert] Unable to start the Phusion Passenger watchdog because it encountered the following error during startup: Unable to start the Passenger core: it seems to have crashed during startup for an unknown reason, with exit code 1 (-1: Unknown error)
  </code></pre>
  
  <hr>
  
  <p>EDIT 3: Attempting to disable nginx server-wide before invoking Passenger:</p>
  
  <pre><code>$ sudo systemctl disable nginx
  Synchronizing state of nginx.service with SysV init with /lib/systemd/systemd-sysv-install...
  Executing /lib/systemd/systemd-sysv-install disable nginx
  insserv: warning: current start runlevel(s) (empty) of script `nginx' overrides LSB defaults (2 3 4 5).
  insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `nginx' overrides LSB defaults (0 1 6).
  
  $ systemctl status nginx
  * nginx.service - Startup script for nginx service
    Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
    Active: inactive (dead)
  
  $ sudo passenger start --port 80 --user node --environment production --daemonize
  Could not start the Nginx engine:
  nginx: [alert] Unable to start the Phusion Passenger watchdog because it encountered the following error during startup: Unable to start the Passenger core: it seems to have crashed during startup for an unknown reason, with exit code 1 (-1: Unknown error)
  </code></pre>