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
events.js:292
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! code ELIFECYCLE
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 127.0.0.1:3000 0.0.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.
Click below to sign up and get $100 of credit to try our products over 60 days!
The newer versions of Digital Ocean’s NodeJS Droplet has some code automatically running when they start the droplet. It is listening on port 3000 already. I was able to stop that process and then run the tutorials fine. I used the software package: sudo apt-get install lsof and then ran lsof -i :3000 to find out what was listening to port 3000. I then stopped that process.
Same problem here. In my case, I tried setting it on port 80 and it still doesn’t work. Please help!
Hi there @dmalvinni,
Did you use the NodeJS image from the Marketplace here:
https://marketplace.digitalocean.com/apps/nodejs
As far as I can see it comes with a demo app on port
3000
and it usespm2
to start the application in case it is stopped. This would explain why the app starts even if you usekill -9
.If this is the case, to stop the application, you can run:
Let me know how it goes! Regards, Bobby