Kill process running on specific ports in Ubuntu and windows | Fix error “Address already in use”

<p>Developers often face errors related to ports that are already in use on their local machines. A common error is &ldquo;Address already in use (EADDRINUSE).&rdquo; As beginners are not usually aware of system commands to find and kill ports, this can become difficult and lead to unnecessary frustration.</p> <blockquote> <p>It is generally fixed in 2 ways.<br /> Start your server on a different port. Or<br /> Free the port by killing the process associated with it.</p> </blockquote> <h1>How to kill ports in Ubuntu</h1> <p>Use the below command to find process ID associated with the port.</p> <pre> lsof -ti :$PORT</pre> <p>Now kill the process ID that you obtain by running above command.</p> <pre> kill $(lsof -ti :$PORT)</pre> <p>There might be some scenarios where you have to pass&nbsp;<code>SIGKILL</code>&nbsp;<a href="https://wikipedia.org/wiki/Signal_%28computing%29" rel="noopener ugc nofollow" target="_blank">signal</a>&nbsp;to stop and kill the process immediately. Use below command.</p> <p><a href="https://lakin-mohapatra.medium.com/kill-process-running-on-specific-ports-in-ubuntu-and-windows-fix-error-address-already-in-use-d0f8c4ea833"><strong>Click Here</strong></a></p>
Tags: Ubuntu Windows