[Solved-5 Solutions] How to fix Error listen Eaddrinuse while using nodejs
Error Description:
If we run a server with the port 80, and we try to use xmlHTTPrequest we get this error: Error: listen EADDRINUSE
- The server is:
And the request:
Solution 1:
EADDRINUSE means that the port number which listen() tries to bind the server to is already in use.
- In your case, there must be running a server on port 80 already.
- If you have another webserver running on this port you have to put node.js behind that server and proxy it through it.
- You should check for the listening event like this, to see if the server is really listening:
Solution 2:
- The killall -9 node, works as expected and solves the problem but you may want to read the answer about why kill -9 may not be the best way to do it.
- On top of that you might want to target a single process rather than blindly killing all active processes.
- In that case, first get the process ID (PID) of the process running on that port (say 8888):
This will return something like:
Solution 3:
- Skype will sometimes listen on port 80 and therefore cause this error if you try to listen on port 80 from Node.js or any other app.
- You can turn off that behaviour in Skype by accessing the options and clicking Advanced -> Connection -> Use port 80 (Untick this)
Solution 4:
- You should try killing the process that is listening on port 80.
- kill all the node apps running. You might not want to do that. With this command you can kill only the one app that is listening on a known port.
If using unix try this command:
Solution 5:
Simply close the terminal and open a new terminal and run