Error: listen EADDRINUSE: address already in use :::3000

Posted September 1, 2020 28.3k views

I recently bought a Digitalocean droplet with the initial $100 account credit and wanted to host a WebRTC video chat that I’ve been working on. I initially hosted it with Heroku, as it was free, but now that I am looking for a more dedicated server, Digitalocean is the immediate answer. However, I am not experienced using PuTTy and VPS’ in general, so I only got the server up and configured correctly yesterday. I was super excited and very eager to test out a better server with dedicated hosting, so I immediately git cloned my Github Repository. I went to run it, npm start, and got an error:

USER***@nodejs-s-1vcpu-1gb-sfo2-01:~/DIRNAME$ sudo npm start

> livestream-server@0.0.1 start /home/USER***/DIRNAME
> node app.js

      throw er; // Unhandled 'error' event

Error: listen EADDRINUSE: address already in use :::3000
    at Server.setupListenHandle [as _listen2] (net.js:1313:16)
    at listenInCluster (net.js:1361:12)
    at Server.listen (net.js:1447:7)
    at Object.<anonymous> (/home/USER***/ZMP_Solutions/app.js:17:8)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1340:8)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 'EADDRINUSE',
  errno: 'EADDRINUSE',
  syscall: 'listen',
  address: '::',
  port: 3000
npm ERR! errno 1
npm ERR! livestream-server@0.0.1 start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the livestream-server@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I researched it a bit, and the error seems to be saying that the port/address that it’s running off of, 3000, is taken. I then ran sudo netstat -lntp | grep 3000 to get info about any operation running on Port 3000. This returned:
tcp 0 0* LISTEN 939/node /var/www/h
A post online said that anything with a /node after it is the PID, which means that 939 should be the PID of the operation taking up that port. I ran sudo kill -9 939, but even after entering my password nothing changed.

Is there a way to fix this? If you need a github repository to test this error, I based most of my code off of this repo which also returns this error when run on my Droplet.


I have also tried switching the port to 2000 and other ports, none of which worked. I also tried running sudo before npm start, to no avail.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi there @dmalvinni,

Did you use the NodeJS image from the Marketplace here:

As far as I can see it comes with a demo app on port 3000 and it uses pm2 to start the application in case it is stopped. This would explain why the app starts even if you use kill -9.

If this is the case, to stop the application, you can run:

  • sudo -u nodejs pm2 stop hello

Let me know how it goes!

Same problem here. In my case, I tried setting it on port 80 and it still doesn’t work. Please help!