nodejs error EADDRINUSE - node.js

I get this when i type "node site.js" im 100% sure im not running this node twice.
Error: listen EADDRINUSE :::3000
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at Server._listen2 (net.js:1262:14)
at listen (net.js:1298:10)
at Server.listen (net.js:1376:9)
at Server.listen.Server.attach (/root/node_modules/socket.io/lib/index.js:228:9)
at Timeout._onTimeout (/root/nodejs/site.js:1005:29)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
code: 'EADDRINUSE',
errno: 'EADDRINUSE',
syscall: 'listen',
address: '::',
port: 3000 }
Im using FEDORA 23

Your site.js tries to listen twice on that port or something (another process) is already listening on port 3000. Find the service and stop/kill it. This command should help: lsof -i | grep 3000

Try running killall node, then node site.js again. If that doesn't work, at least you can rule out Node from the cause of this.

Your site is listening twice to that port. You can check in your code whether you have 2 instructions .listen()

Related

cant access the webapp running in docker with docusaurus

I have built a docker container with docusaurus server and opened port, but the website is not accessible and throws an error like this. How do I allow all the ip address in the docusaurus server?
yarn run v1.22.19
warning package.json: No license field
$ docusaurus-start
LiveReload server started on port 35729
Docusaurus server started on port 3000
Request failed: Error: connect ECONNREFUSED 127.0.0.1:80
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16) { errno: -111, code: 'ECONNREFUSED', syscall: 'connect',
address: '127.0.0.1', port: 80 }

Getting an error while running "nodemon app" comannd

i've downloaded express package and nodemon, I created a server and rendered all of my ejs files . while running "nodemon app" command I'm getting this error, what specifically the problem is? :
PS C:\Users\user\Desktop\my port> nodemon app
[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node app.js`
events.js:291
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1316:16)
at listenInCluster (net.js:1364:12)
at Server.listen (net.js:1450:7)
at Function.listen (C:\Users\user\Desktop\my port\node_modules\express\lib\application.js:618:24)
at Object.<anonymous> (C:\Users\user\Desktop\my port\app.js:16:5)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
at Module.load (internal/modules/cjs/loader.js:1100:32)
at Function.Module._load (internal/modules/cjs/loader.js:962:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1343:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -4091,
syscall: 'listen',
address: '::',
port: 3000
}
[nodemon] app crashed - waiting for file changes before starting...
Your system has something already running on port 3000.
you can do either of 2,
Kill process running on 3000
Or Use different port in your current app (like 3001, 5000, etc)
hi use this and kill the process directly;
netstat -ano | findstr :XXXX
XXXX <<<<----put the number of the port you have problem, system show it always, then when you press enter the system show you a message with a real port that one is what you need killing, so put this:
taskkill /F /PID XXXX
XXXX <<<<----the number of the port you want to kill and what system gave you after the first command
type this in command prompt
netstat -ano | findstr :XXXX <-THIS IS THE PORT NUMBER YOU used
And it will give you something like this
TCP 0.0.0.0:8080 || 0.0.0.0:0 || LISTENING | tttt
TCP [::]:8080 || [::]:0 || LISTENING || tttt<--thiss is the number you needed
then type this in command prompt
taskkill /PID tttt /F <--then enter
result will be something like -->
The process with PID tttt has been terminated.

node running server throw Error regarding already runinng port

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: 8082
}
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::8082
First findout your processID for your running process
lsof -i:1234(your port ID)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Google 55523 ssurisettii 42u IPv6 0x53ab9cb514809733 0t0 TCP localhost:53991->localhost:us-cli (CLOSE_WAIT)
Google 55523 ssurisettii 45u IPv6 0x53ab9cb51480d473 0t0 TCP localhost:53989->localhost:us-cli (CLOSE_WAIT)
Google 55523 ssurisettii 46u IPv6 0x53ab9cb514809d53 0t0 TCP localhost:53990->localhost:us-cli (CLOSE_WAIT)
this ways shows,
Now you kill the your related processID
suppose your port id contains processID 1234
then **** kill -9 1234 ***

Amazon EC2 Error: listen EACCES 0.0.0.0:80

I have already added the HTTP TCP Port 80 to the inbound rules, but I still get the error:
Error: listen EACCES 0.0.0.0:80
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at Server.setupListenHandle [as _listen2] (net.js:1338:19)
at listenInCluster (net.js:1396:12)
at doListen (net.js:1505:7)
at _combinedTickCallback (internal/process/next_tick.js:141:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
at Function.Module.runMain (module.js:695:11)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
You probably have to run your node.js script with sudo as you want to listen on port 80.
You cannot run a process that listens on low ports (below 1024) without root privileges.
You either try to run as sudo, as stated above, or start to use a reverse proxy (nginx for instance), start the process on another port and use the reverse proxy to forward the calls from port 80 to whatever port you started the process on.
The error code EACCES means you don't have proper permissions to run applications on that port. On Linux systems, any port below 1024 requires root access.
you need to use reverse proxy to forward the calls from port 80 to 8080 for example.

I'm getting an unhandled error when trying to run node server

So, I'm really new to node and I feel like this might be something very simple but I can't figure it out. I installed the dependencies but when I try to start the server by doing "node server" I get this error:
Vladimirs-MBP:comeat-server Vladimir$ node server
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRNOTAVAIL 18.194.133.202:3001
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at Server.setupListenHandle [as _listen2] (net.js:1350:19)
at listenInCluster (net.js:1408:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1517:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:10)
Your 3001 port is already used by some service, please change the port
var http = require('http');
//create a server object:
http.createServer(function (req, res) {
res.write('Hello World!'); //write a response to the client
res.end();
}).listen(8080); //the server object listens on port 8080
You can use these commands to check what ports are being used:
1. sudo lsof -i -P -n | grep LISTEN
2. netstat -tulpn | grep LISTEN
You can kill that process number using
sudo kill -9 process_number
Your 3001 port is in use. you should use another port or kill 3001 port and then use it.
for example
sudo kill -9 $(sudo lsof -t -i:3001)

Resources