Skip to content
npm

How to kill a process running on a port

Mar 5, 2023Abhishek EH1 Min Read
How to kill a process running on a port

Have you received errors like this while starting a server in localhost?

1Something is already running on port 3000.

Or

1Error: listen EADDRINUSE: address already in use :::8080

You most probably will know the reason for this from the error message. However, to fix this, you will have to find the process which is using the port and kill it.

We have an easy solution for you, which works across the operating systems. You can use the npm package kill-port to achieve this.

The syntax to use it is npx kill-port <port_number>.

Eg:

1npx kill-port 3000

Now your port 3000 will be freed and you can start your application on port 3000.

If you need to kill ports often, you can install kill-port globally using the following command:

1npm i -g kill-port

Now, all you need to run is:

1kill-port 3000

If you have liked article, stay in touch with me by following me on twitter.

Leave a Comment

© 2023 CodingDeft.Com