Nodejs Throwing following error [closed] - node.js

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am running rest api using node and restify on mac-book. I am not sure why I am getting following error. I tried updating npm packages but nothing work. Thanks in advance!!
Error: listen EADDRINUSE :::7088
at Server.setupListenHandle [as _listen2] (net.js:1330:14)
at listenInCluster (net.js:1378:12)
at Server.listen (net.js:1465:7)
at Server.listen (/Users/rahul/Development/projects/inventory-manager/node_modules/restify/lib/server.js:404:32)
at spawnWorker (/Users/rahul/Development/projects/inventory-manager/src/server.js:20:10)
at run (/Users/rahul/Development/projects/inventory-manager/src/server.js:81:5)
at Object.<anonymous> (/Users/rahul/Development/projects/inventory-manager/src/server.js:86:1)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at loader (/Users/rahul/Development/projects/inventory-manager/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/rahul/Development/projects/inventory-manager/node_modules/babel-register/lib/node.js:154:7)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at Object.<anonymous> (/Users/rahul/Development/projects/inventory-manager/node_modules/babel-cli/lib/_babel-node.js:154:22)
at Module._compile (internal/modules/cjs/loader.js:702:30)
Emitted 'error' event at:
at Server.emit (events.js:182:13)
at Server.EventEmitter.emit (domain.js:442:20)
at emitErrorNT (net.js:1357:8)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:746:11)
at Object.<anonymous> (/Users/rahul/Development/projects/inventory-manager/node_modules/babel-cli/lib/_babel-node.js:154:22)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
[... lines matching original stack trace ...]
at startup (internal/bootstrap/node.js:238:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)
error: Forever detected script exited with code: 1
error: Script restart attempt #22
events.js:167
throw er; // Unhandled 'error' event
^

Q: Why was my node process not able to boot up?
A: This is the reason why your application was dying.
Error: listen EADDRINUSE :::7088
It means that another process is already on port 7088 and your node process was not able to bind to it.

I encountered this problem couple of times before,
Just change the port for node from 7088 to any other port

Related

Error: listen EACCES: permission denied on windows

Good day,
I have been trying to get an IPC server working for child processes to communicate with each other. I followed this SO answer (Communication between child processes in Node.js) to try creating an IPC server between two child processes. However, I get this error on windows:
PS F:\Node Projects\communication-between-child-process-node-js> node parent
events.js:377
throw er; // Unhandled 'error' event
^
Error: listen EACCES: permission denied F:\Node Projects\communication-between-child-process-node-js/sibling.sock
at Server.setupListenHandle [as _listen2] (net.js:1314:21)
at listenInCluster (net.js:1379:12)
at Server.listen (net.js:1476:5)
at Object.<anonymous> (F:\Node Projects\communication-between-child-process-node-js\parent.js:17:10)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
at internal/main/run_main_module.js:17:47
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1358:8)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
code: 'EACCES',
errno: -4092,
syscall: 'listen',
address: 'F:\\Node Projects\\communication-between-child-process-node-js/sibling.sock',
port: -1
}
What am I doing wrong? I have everything set up the way it was in that SO answer. I think it's a windows issue but does anyone know how to give permission to use the socket?
Since you're using Windows, the following documentation is relevant:
On Windows, the local domain is implemented using a named pipe. The path must refer to an entry in \\?\pipe\ or \\.\pipe\. Any characters are permitted, but the latter may do some processing of pipe names, such as resolving .. sequences. Despite how it might look, the pipe namespace is flat. Pipes will not persist. They are removed when the last reference to them is closed. Unlike Unix domain sockets, Windows will close and remove the pipe when the owning process exits.
The documentation also shows an example on how to create a socket file path:
path.join('\\\\?\\pipe', process.cwd(), 'myctl')

Unable to start node.js application written with graphql

I have an application written in node.js with graphql, it is running on ubuntu sever, however, i cloned the code onto my local windows 10, installed all packages, and node environment, but when I try to start the app with "node index.js" I got the following error.
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be one of type string or Buffer. Received type object
at validChunk (_stream_writable.js:263:10)
at WriteStream.Writable.write (_stream_writable.js:297:21)
at Object.<anonymous> (D:/MyProjects/appletree/apple-tree-backend/configs/constants.js:5:17)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at loader (D:\MyProjects\appletree\apple-tree-backend\node_modules\babel- register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (D:\MyProjects\appletree\apple- tree-backend\node_modules\babel-register\lib\node.js:154:7)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
Emitted 'error' event at:
at errorOrDestroy (internal/streams/destroy.js:107:12)
at validChunk (_stream_writable.js:266:5)
at WriteStream.Writable.write (_stream_writable.js:297:21)
[... lines matching original stack trace ...]
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Thanks for answering, I figured out the issue later as I looked into the code, the project used dotenv package which requires a .env file and this file is not included in the source code that's why I couldn't start the code on my local. I got the .env file from the production server and now the code can run on my local , thanks everyone.

My node process doesn't end on my EC2 server

SO I made an EC-2 Server and I've installed node.js on it. Then, I connected it to port :3000. It was fine untill I noticed that the port was never closed. I had no idea it was still open and tried 'npm run start' multiple times. I just found out that it was alive so I got the PID through "lsof -i TCP:3000" and killed it using 'Kill -9 "PID#" and tried to run the port again. However, it gave me :
node:events:342
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (node:net:1306:16)
at listenInCluster (node:net:1354:12)
at Server.listen (node:net:1441:7)
at Function.listen (/home/ec2-user/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/home/ec2-user/index.js:12:5)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1333:8)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '::',
port: 3000
}
So I searched if the port was open again, and it was still open with a different PID. I tried killing it over and over, but it kept showing up with a differnt PID.
If there is something worng or unclear with my question please tell me, I jsut started fiddling with EC2 and all this server things, so I don't know which informations are further required to solve this.
I solved it!!! I typed
killall5 -9
and killed everything and it stopped!

error that wont go away despite numerous changes in node.js

Good evening,
I have the following error and I have no idea what it means, i have googled and changed a few little bit but its very persistent. Is anyone able to offer me some help with the matter?
events.js:292
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::5000
at Server.setupListenHandle [as _listen2] (net.js:1318:16)
at listenInCluster (net.js:1366:12)
at Server.listen (net.js:1452:7)
at Object.<anonymous> (/Users/danielwilstrop/Desktop/projects/live-chat-2/server.js:100:8)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1345:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 5000
}
[nodemon] app crashed - waiting for file changes before starting...
This error is usually caused by a typo on your terminal.
Check if you typed the correct file name in your terminal and also check if the path to your file is correct.
Option 2: check if no other terminals are open in the background. kill all those other terminals, press Ctr+C then run your app again..
There is some other process already using port 5000 so, you are getting this error. To solve this there are two ways
Change the server port from 5000 to something else which port is available eg. 5555 in this file /Users/danielwilstrop/Desktop/projects/live-chat-2/server.js at line number 100 (as shown in the error)
Kill the process that is running on port 5000. Then run the server.js file.
For Linux or mac sudo lsof -ti tcp:5000 | sudo xargs kill
For windows run cmd with administrator privilages netstat -ano|findstr "PID :5000" take the process id from the output and then taskkill /pid <PROCESS_PID_USING_PORT_5000> /f

Error: listen EADDRINUSE: address already in use :::8080 while clicking on run script

Firstly I run this command (npm ndb server.js) then a debugging chrome window appear and after this
Actually, I got these error when I am trying to debug in my code and I clicked on run script after that a debugging chrome window appear then it give these wired error.
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::8080
at Server.setupListenHandle [as _listen2] (net.js:1279:14)
at listenInCluster (net.js:1327:12)
at Server.listen (net.js:1414:7)
at Function.listen (C:\Users\Abhishek kumar\natours\node_modules\express\lib\application.js:618:24)
at Object.<anonymous> (C:\Users\Abhishek kumar\natours\server.js:24:5)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Emitted 'error' event at:
at emitErrorNT (net.js:1306:8)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
The error is quite explicit :
Error: listen EADDRINUSE: address already in use :::8080
means that some program is already listening on port 8080 (and you have an extra hint : the ::: says that it's listening on broadcast host using IPv6).
If you're curious what program is listening on that port, you could try to navigate to http://localhost:8080 and see what's displayed. If nothing is displayed then it's not one of your web apps. Maybe you have an HTTP proxy running on your machine (I have recently come across a malware that ran mitmproxy on target machines on port 8080 to intercept all traffic).
On Mac or Linux you can use lsof to get more information on the program listening on that port.
The command you want is :
$ sudo lsof -i :8080
Run this command.
killall node

Resources