I am trying to debug my code using node-inspector but I am getting this error in my Terminal window again and again
$ sudo sails debug
info: Running app in debug mode...
info: You probably want to install / run node-inspector to help with debugging!
info: https://github.com/node-inspector/node-inspector
info: ( to exit, type <CTRL>+<C> )
Error: listen EADDRINUSE
at exports._errnoException (util.js:746:11)
at Agent.Server._listen2 (net.js:1156:14)
at listen (net.js:1182:10)
at Agent.Server.listen (net.js:1267:5)
at Object.start (_debugger_agent.js:20:9)
at startup (node.js:86:9)
at node.js:814:3
To resolve
Error : listen EADDRINUSE
I have tried closing other Terminal window (in which my node-inspector was running).
I have referred to the answers already here on StackOverflow but they didn't work
I have even tried giving this command to kill processes :
$ killall -9 node
No matching processes belonging to you were found
but still its not working.
Somebody please help me out with this.
I see that you are using sudo so this is not a permissions issue.
It definitely seems like the port is already in use. You should check to see which process is using the port, then kill that process.
There is a known issue with using sails debug on Node v12.0. There's a patch which will be released with the next version of Sails (v0.12).
In the meantime you can either install the edge version of Sails from Github or apply the patch yourself by replacing your Sails' /lib/hooks/grunt/index.js file with the contents of https://raw.githubusercontent.com/balderdashy/sails/88ffc0ed9949f8c74ea390efb5610b0e378fa02c/lib/hooks/grunt/index.js.
First, find your task that uses port 1337:
netstat -ano | findstr : 1337 (port number)
Then kill it:
tskill (process ID (PID))
It can solve your problem
I am using Neo4j 2.0.3 Community server by installing it on my linux system (by unzipping the tar.gz). I got this error while I tried to start the server
WARNING! You are using an unsupported Java runtime.
process [50690]... waiting for server to be ready.neo4j-community-2.0.3/bin/neo4j: line 147: lsof : command not found
.neo4j-community-2.0.3/bin/neo4j: line 147: lsof : command not found
.neo4j-community-2.0.3/bin/neo4j: line 147: lsof : command not found
. Failed to start within 120 seconds.
Neo4j Server may have failed to start, please check the logs.
I checked for the solution for this and came to know that /usr/sbin had to be added to the path. On doing so and restarting the server, I got the following message
Another server-process is running with [40903], cannot start a new one. Exiting.
However, when I run the command neo4j staus , it says
Neo4j Server is not running
Can anybody please help me with how should I get started with it?
This is very late, but might help others.
If it tells you this, and you check that process id with, for example, ps aux | grep 40903, and it's not neo4j, the problem might be that the port is being used.
By default neo4j uses 7474, but can change this on the neo4j folder /conf/neo4j-server.properties and that was my problem, I had set the port to '22' which was being used. SO make sure it is set to a port that is open and available.
Hope this helps.
You might want to examine the startup script.
Another server-process is running with [40903], cannot start a new one. Exiting.
indicates (me to) that there might be a pid file (or the script uses them) which was written and is checked before attempting to start a new instances. This the normal thing to do.
I think you need to kill the other process using kill
You can see this answer for how to kill the process:
https://unix.stackexchange.com/questions/8916/when-should-i-not-kill-9-a-process
Otherwise, restarting the operating system will also do the job. For me, I normally start neo4j in the console, as in ./neo4j console. This makes it easier to stop the process.
I created expressjs application using the following commands:
express -e folderName
npm install ejs --save
npm install
When I run the application with: node app.js, I have the following errors:
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:884:11)
at Server._listen2 (net.js:1022:14)
at listen (net.js:1044:10)
at Server.listen (net.js:1110:5)
at Object.<anonymous> (folderName/app.js:33:24)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
How to fix it?
You had run another server use the same port like 8080.
Maybe you had run node app in other shell, Please close it and run again.
You can check PORT no. is available or not using
netstat -tulnp | grep <port no>
Alternatively, you can use lsof:
lsof -i :<port no>
We do get similar error when we sometimes run our express app. We have to follow the same in that case. We need to check if its running in any terminal.
If you want to find and kill process, follow these steps:
ps aux | grep node
Find the process ID (second from the left):
kill -9 PRCOCESS_ID
OR
Use a single command to close all the running node processes.
ps aux | awk '/node/{print $2}' | xargs kill -9
An instance is probably still running.
This will fix it.
killall node
Update: This command will only work on Linux/Ubuntu & Mac.
If you're on Linux, this problem can also occur if Nodejs is not running as root.
Change from this:
nodejs /path/to/script.js
To this:
sudo nodejs /path/to/script.js
Just happened to me and none of the other suggestions here fixed it. Luckily I remembered the script was working the other day when running as root. Hope this helps someone!
Disclaimer: This probably isn't the best solution for a production environment. Starting your service as root may introduce some security holes to your server/application. In my case, this was a solution for a local service, but I'd encourage others to spend some more time trying to isolate the cause.
This is because the port you are using to run the script is already in use.
You have to stop all other nodes which are using that post.
for that, you can check all node by
ps -e
OR for node process only use ps -ef | grep node
This will give you the list of all node process with id
to Kill all node process
sudo killall -9 node
Or for the specific id sudo kill -9 id
I fixed the bug by changing the port which was
app.set('port', process.env.PORT || 3000);<br>
and changed to:
app.set('port', process.env.PORT || 8080);<br>
The port Node is trying to use can be already used by another program. In my case it was ntop, which I had recently installed. I had to open http://localhost:3000/ in a browser to realize it. Another way to find the process is given here.
Reason for this error
Some other process is already running on the port you have specified
Simple and Quick solution
On Linux OS, For example you have specified 3000 as the port
Open the terminal and run lsof -i :3000. If any process is already running on port 3000 then you will see this printing on the console
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 16615 aegon 13u IPv6 183768 0t0 TCP *:3000 (LISTEN)
Copy the PID (process ID) from the output
Run sudo kill -9 16615 (you have to put PID after -9)
Start the server again
Close any other node servers that are running, even if they are in other terminal windows or running on different ports. That should fix the problem.
If you want to use the same port number then type kill % in the terminal, which kills the current background process and frees up the port for further usage.
this means your file is running now. just enter below code and try again:
sudo pkill node
Actually Ctrl+C keys not releasing port used by node process. So there is this error.
The resolution to the issue was using following code snippet in server.js:
process.on('SIGINT', function() {
console.log( "\nGracefully shutting down from SIGINT (Ctrl-C)" );
// some other closing procedures go here
process.exit(1);
});
This worked for me.
You can also check for other solutions mentioned at Graceful shutdown in NodeJS
If you've tried killing all node instances and other services listening on 3000 (the default used by the express skeleton setup) to no avail, you should check to make sure that your environment is not defining 'port' to be something unexpected. Otherwise, you'll likely get the same error. In the express skeleton's app.js file you'll notice line 15:
app.set('port', process.env.PORT || 3000);
In-order to fix this, terminate or close the server you are running.
If you are using Eclipse IDE, then follow this,
Run > Debug
Right-click the running process and click on Terminate.
events.js:183 throw er; // Unhandled 'error' event
I also got the same kind of problem and tried many ways but finally got this, this works well:
npm install ws#3.3.2 --save-dev --save-exact
Refer to this link for more clarifications https://github.com/ionic-team/ionic-cli/issues/2922
I ran into the same issue today and the port was not used. The following approach helped:
rm -rf node_modules && npm cache clean && npm install
npm start
On windows :
cmd 1 : lsof -i :<port no>
This gives the process id
cmd 2 : kill -9 <process id>
done
In my case I've had to run vagrant reload as well. Even with no node processes running my express app in my virtual machine I was still getting this error until reloading the vagrant box.
Stop the service that is using that port.
sudo service NAMEOFSERVICE stop
In my case the issue was caused by forgetting to call next() in an expressjs `use' method call.
If the current middleware does not end the request-response cycle, it must call next() to pass control to the next middleware, otherwise the request will be left hanging.
http://expressjs.com/guide/using-middleware.html
This worked for me.
http://www.codingdefined.com/2015/09/how-to-solve-nodejs-error-listen.html
Just change the port number from the Project properties.
You can also change the port from Gruntfile.js and run again.
After killing the same process multiple times and not being able to locate what else was running on port 8000, I realized I was trying to run on port 8000 twice:
Before:
MongoClient.connect(db.url, (err, database) => {
if (err) return console.log(err);
require('./app/routes')(app, database);
app.listen(port, () => {
console.log('We are live on ' + port);
});
});
require('./app/routes')(app, {});
app.listen(port, () => {
console.log("We are live on " + port);
});
After:
MongoClient.connect(db.url, (err, database) => {
if (err) return console.log(err);
require('./app/routes')(app, database);
app.listen(port, () => {
console.log('We are live on ' + port);
});
});
require('./app/routes')(app, {});
I had the same problem and I found out, that a nodejs process that I had previously canceled with CTRL+C was still running. The problem in Windows 10 is, that Ctrl + C Doesn't Kill Gracefully nodejs. I opened the task manager and killed the process manually. The solutions provided on GitHub didn't work for me.
If you using windows, then you can end process from task manager for node.js
None of the answers worked for me.
When I restarted my computer I could get the server up and running.
Mac
shutdown now -r
Linux
sudo shutdown now -r
->check what’s running on port 8080 or what ever port u want to check
lsof -i #localhost:8080
if something is running u can close it or use some kill command to close it
Simple just check your teminal in Visual Studio Code
Because me was running my node app and i hibernate my laptop then next morning i turn my laptop on back to development of software. THen i run the again command nodemon app.js
First waas running from night and the second was running my latest command so two command prompts are listening to same ports that's why you are getting this issue.
Simple Close one termianl or all terminal then run your node app.js or nodemon app.js
The port you are listening to is already being listened by another process.
When I faced to this error I killed the process using Windows PowerShell (because I used Windows)
List itemopen the windows powershell
type ps and then you can get list of processes
find the process named node, and note the Id
type Stop-process <Id>
I think that it is help for windows users
IF it is in mac then it's all about IP of x86_64-apple-darwin13.4.0. If you follow errors it would be something related to x86_64-apple-darwin13.4.0. Add
127.0.0.1 x86_64-apple-darwin13.4.0
to /etc/hosts file. Then the problem is gone