Monday, 12 June 2017

Error: listen EADDRINUSE :::443 error when trying to start nodejs server

I am trying to create a nodejs application that uses SSL. I have the cert, domain, and nodejs configured and working, but I'm having a problem sometimes when I stop my node server using Ctrl+C. I am getting the following error when trying to restart the node server:

Error: listen EADDRINUSE :::443
    at Object.exports._errnoException (util.js:870:11)
    at exports._exceptionWithHostPort (util.js:893:20)
    at Server._listen2 (net.js:1237:14)
    at listen (net.js:1273:10)
    at Server.listen (net.js:1369:5)
    at Object.<anonymous> (/var/www/html/server.js:212:47)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)

Now I know this means that the port is in use, but I've tried several things to find the process that is using that port but I cant. A couple thing I've tried that are worth mentioning are netstat:

$ sudo netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1164/sshd       
tcp6       0      0 :::22                   :::*                    LISTEN      1164/sshd       
udp        0      0 0.0.0.0:68              0.0.0.0:*                           882/dhclient

and ps:

$ ps aux |grep node
ubuntu    7632  0.0  0.0  12944   988 pts/0    S+   23:30   0:00 grep --color=auto node

but neither of them show me what is using port 443. I have pm2 to keep my node server in a running state, but it keeps saying errored and then I find the EADDRINUSE errors in the pm2 error log. I've been banging my head against the wall for hours. Can anyone assist me? Thanks!



via Alan

No comments:

Post a Comment