{"id":1289,"date":"2021-10-13T11:00:49","date_gmt":"2021-10-13T09:00:49","guid":{"rendered":"https:\/\/nguenkam.com\/blog\/?p=1289"},"modified":"2021-11-03T14:52:41","modified_gmt":"2021-11-03T13:52:41","slug":"how-to-kill-terminate-the-process-on-specific-port","status":"publish","type":"post","link":"https:\/\/nguenkam.com\/blog\/index.php\/2021\/10\/13\/how-to-kill-terminate-the-process-on-specific-port\/","title":{"rendered":"How to kill\/terminate  the process on specific port ?"},"content":{"rendered":"\n<p>Let\u00b4s say we have this warning &#8220;<em><strong>Port 4200 is already in use&#8221; when running the ng serve command<\/strong><\/em>&#8220;.<\/p>\n\n\n\n<p>And all the  (IDE) terminal are closed.<\/p>\n\n\n\n<p>This is what I used to kill the progress on port 4200 :<\/p>\n\n\n\n<p><strong>For linux users:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo kill $(sudo lsof -t -i:4200)<\/code><\/pre>\n\n\n\n<p>You could also try this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo kill `sudo lsof -t -i:4200`<\/code><\/pre>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>For windows users:<\/strong><\/p>\n\n\n\n<p>Port number 4200 is already in use. Open the cmd as administrator. Type below command in cmd:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>netstat -a -n -o<\/code><\/pre>\n\n\n\n<p>And then, find port with port number 4200 by right click on terminal and click find, enter 4200 in &#8220;find what&#8221; and click &#8220;find next&#8221;: Let say you found that port number 4200 is used by pid 18932. Type below command in cmd:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>taskkill -f \/pid 18932<\/code><\/pre>\n\n\n\n<p><strong>Windows User ( Alternative 2<\/strong>)<\/p>\n\n\n\n<p>Open your&nbsp;<code>cmd.exe<\/code>&nbsp;as&nbsp;<code>administrator<\/code>,<\/p>\n\n\n\n<p>then Find the&nbsp;<code>PID<\/code>&nbsp;of&nbsp;<code>port 4200<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>netstat -ano | findstr :4200<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-embed is-provider-imgur wp-block-embed-imgur\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/i.stack.imgur.com\/mOSAv.png\n<\/div><\/figure>\n\n\n\n<p>Here I have 3 PID :<\/p>\n\n\n\n<ul><li>Red one is from &#8220;ng-serve&#8221; (127.0.0.1:4200) that&nbsp;<code>LISTENING<\/code><\/li><li>Green one is from &#8220;your browser&#8221;<\/li><\/ul>\n\n\n\n<p>kill only port 4200 (kill the red PID):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>taskkill \/PID 15940 \/F<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-embed is-provider-imgur wp-block-embed-imgur\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/i.stack.imgur.com\/ATfte.png\n<\/div><\/figure>\n\n\n\n<p><em>note : kill the green one will only lead your browser closed by force.<\/em><\/p>\n\n\n\n<p>now you can do &#8220;ng-serve&#8221; to start your angular app at the same port 4200<\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>For UNIX:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>alias ngf='kill -9  $(lsof -t -i:4200);ng serve'<\/code><\/pre>\n\n\n\n<p>Now run&nbsp;<strong>ngf<\/strong>&nbsp;(instead of&nbsp;<em>ng serve<\/em>) in terminal from the project folder. This will kill all processes using the port 4200 and runs your Angular project.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let\u00b4s say we have this warning &#8220;Port 4200 is already in use&#8221; when running the ng serve command&#8220;. And all the (IDE) terminal are closed. This is what I used to kill the progress on port 4200 : For linux users: You could also try this: For windows users: Port number 4200 is already in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1344,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[37],"tags":[355,348,269,354,345,188,161,217],"_links":{"self":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1289"}],"collection":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1289"}],"version-history":[{"count":2,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1289\/revisions"}],"predecessor-version":[{"id":1345,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1289\/revisions\/1345"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/1344"}],"wp:attachment":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}