Developers often face errors related to ports that are already in use on their local machines. A common error is “Address already in use (EADDRINUSE).” As beginners are not usually aware of system commands to find and kill ports, this can become difficult and lead to unnecessary frustration.
It is generally fixed in 2 ways.
Start your server on a different port. Or
Free the port by killing the process associated with it.
How to kill ports in Ubuntu
Use the below command to find process ID associated with the port.
lsof -ti :$PORT
Now kill the process ID that you obtain by running above command.
kill $(lsof -ti :$PORT)
There might be some scenarios where you have to pass SIGKILL signal to stop and kill the process immediately. Use below command.