0

My app was not running but when I try "npm start" command it throws error

Error: listen EADDRINUSE: address already in use :8080

I restart my EC2 instance and try this command again, but I face same error. How do I start my Node server?

Amit Shakya
  • 748
  • 3
  • 8
  • 25
  • Do you have another process/server running at the same time? Also please provide a minimal reproducible sample or at least more context – MrCodingB May 15 '21 at 18:48
  • @MrCodingB No I didn't running any other process, for confusion I restart my ec2 instance but still I am facing this error. – Amit Shakya May 15 '21 at 18:50
  • run `netstat -p -l | grep 8080` to see which process holds port 8080 – obe May 15 '21 at 18:53
  • @obe this command shows nothing...... – Amit Shakya May 15 '21 at 18:55
  • @AmitShakya Do you see anything with ```ps -eaf|grep 8080``` or ```lsof -i tcp:8080``` – Ramaraja Ramanujan May 15 '21 at 19:05
  • Have you checked you're not having your node app call `app.listen(8080)` twice by accident? – IAmDranged May 15 '21 at 19:10
  • @IAmDranged yes I have checked that, even I have restart my server instance as well to remove all confusion. but still facing this issue – Amit Shakya May 15 '21 at 19:13
  • @RamarajaRamanujan I got this output lsof -i tcp:8080 -> node 3255 root 20u IPv6 20660 0t0 TCP *:webcache (LISTEN) || ps -eaf|grep 8080 -> root 5251 4938 0 19:22 pts/3 00:00:00 grep --color=auto 8080 What does it mean??? I am new for Node – Amit Shakya May 15 '21 at 19:23
  • Does this answer your question? [Node / Express: EADDRINUSE, Address already in use - Kill server](https://stackoverflow.com/questions/4075287/node-express-eaddrinuse-address-already-in-use-kill-server) – Showrin Barua May 15 '21 at 19:26

1 Answers1

1

Going by your comments, it looks like you have a node process already running your EC2 instance and it's listening on port 8080.
As you have stated lsof -i tcp:8080 gives you,

node 3255 root 20u IPv6 20660 0t0 TCP *:webcache (LISTEN)

The PID of this process is shown in the 2nd column: 3255.
Kill it,

kill -9 3255

After this try running your npm start and it should work

Ramaraja Ramanujan
  • 1,908
  • 12
  • 18