Quick way to fix the Port is Already in Use Error
Have you ever struggled with the
the port is already in use error while starting the application?
A lot of times when we are using multiple applications or forget to stop the previous process, we get the
the port is already in use error.
Then we try to find the process using that port and then kill it or maybe restart the machine.
There is an easier way to do it. Just execute the following command in the terminal:
npx kill-port port_number
and the process using that port will be killed.
npx kill-port 3000
will kill the process using port 3000.
To kill multiple ports pass the ports separated by space
npx kill-port 3000 5000 7000
kill-port in an npm package which helps in killing any specified port or multiple ports at once.
If you want, you can install the
kill-port npm package on your machine by running the following command:
npm install -g kill-port
Mac/Linux users may need to add
sudoin front of it like this:
sudo npm install -g kill-port.
Once installed, you can just execute the
kill-port 3000 to kill the process using port 3000.
Thanks for reading
- ES6 Destructuring
- Import and Export Syntax
- Arrow functions
- Optional chaining operator and a lot more.
Check out free preview contents of the book here.
Also, you can check out my free Introduction to React Router course to learn React Router from scratch.