-4

I am running a very simple node code and I'm not using any other project, every time im running node server.js i got this error : Error: listen EADDRINUSE: address already in use :::5000 But at the same time im not using any other project or server

const express = require("express");
const app = express();
app.listen(5000, () => {
  console.log("Server has started on port 5000");
});
jj-ammar
  • 35
  • 5

1 Answers1

-1

That means you already have a service running on the same port. So you have to shutdown(kill) that service(process). To kill the process, you must know process id. To check process id, type this cmd ps -ah. And you will see the running node process and its pid(process id).

The final thing is to kill process, type kill (pid)

  • ps -ah PID TTY TIME CMD 646 ttys000 0:00.01 /usr/bin/login -fqpl jj /Applications/iTerm.app/Contents/MacOS/ShellLauncher --launch_shell 647 ttys000 0:00.41 -zsh 6757 ttys000 0:00.01 ps -ah 3585 ttys002 0:00.10 /bin/zsh -il 3611 ttys003 0:00.03 /bin/zsh -il 5935 ttys004 0:00.04 -zsh – jj-ammar Apr 03 '23 at 08:07
  • i kill this as you said but ➜ kill 5000 kill: kill 5000 failed: no such process – jj-ammar Apr 03 '23 at 08:07
  • ➜ kill 5935 kill: kill 5935 failed: no such process – jj-ammar Apr 03 '23 at 08:07
  • 1
    You shouldn't blindly kill processes. – jabaa Apr 03 '23 at 08:57