When trying to start my node express service, I am having trouble with the infamous error "listen EADDRINUSE."
Here's the line where I attempt to call listen:
var server = app.listen(3000, function() {
console.log("listening on port %d", server.address().port);
});
The thing is, I can't find any other node process running, nor does anything show running on port 3000.
Here are the results I get for those inquiries:
$ ps aux | grep node
ec2-user 7780 0.0 0.0 110280 848 pts/1 S+ 17:41 0:00 grep node
$ nestat -anp | grep 3000
<nothing>
This is quite baffling. I could try to recycle the box, but it's running a live site and I'm reluctant to do that.
Is there anything else I can do to try to troubleshoot this?
EDIT: Thanks, Ali, for suggesting the obvious thing that I somehow missed. I am now up and running on port 3300. But, when I check netstat I don't see 3300 in there either. Which suggests to me that I have some sort of process running on 3000 that I don't know how to find. For the record, this is an AWS Linux AMI.
Maybe your process doesn't stop while you are stopping your program in those ports. try to run these commands in your terminal.
lsof -i:<your port number>
If you got a table then it means your process is not killed, copy that PID from that table and run this command
kill -9 <PID>
this will kill the process running on that port, after this, you can use this port for your program.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With