{"id":1230,"date":"2021-07-09T09:07:28","date_gmt":"2021-07-09T07:07:28","guid":{"rendered":"https:\/\/nguenkam.com\/blog\/?p=1230"},"modified":"2022-10-12T09:44:28","modified_gmt":"2022-10-12T07:44:28","slug":"how-to-find-out-which-program-is-using-a-particular-port","status":"publish","type":"post","link":"https:\/\/nguenkam.com\/blog\/index.php\/2021\/07\/09\/how-to-find-out-which-program-is-using-a-particular-port\/","title":{"rendered":"How to find out which program is using a particular port?"},"content":{"rendered":"\n<p><span class=\"has-inline-color has-vivid-cyan-blue-color\"><em><strong>Let\u00b4s say , we want to find out which program is  using the port 80  and 443 in our computer.<\/strong><\/em> <\/span> <em>(The port number started with 80 or 443)<\/em>  <\/p>\n\n\n\n<p>Enter the following at the prompt (cmd): <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>netstat -ano | findstr \/r 0.0:80 &amp;&amp; netstat -ano | findstr 0.0:443<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"753\" height=\"76\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/07\/image-1.png\" alt=\"\" class=\"wp-image-1231\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/07\/image-1.png 753w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/07\/image-1-300x30.png 300w\" sizes=\"(max-width: 753px) 100vw, 753px\" \/><\/figure>\n\n\n\n<p>In the last column, you can see the process ID. Here for example <strong>4<\/strong> for the port<em> 80<\/em>, and<strong> 14256<\/strong> for the port<em> 8000<\/em>.<\/p>\n\n\n\n<p>Now, let\u00b4s insert this ID in the following command :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tasklist \/FI \"PID eq 4\" \/FO TABLE<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"700\" height=\"105\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/07\/image-2.png\" alt=\"\" class=\"wp-image-1232\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/07\/image-2.png 700w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/07\/image-2-300x45.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/figure>\n\n\n\n<p>In this case, &#8220;System&#8221; uses port 80.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"693\" height=\"111\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/07\/image-3.png\" alt=\"\" class=\"wp-image-1233\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/07\/image-3.png 693w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/07\/image-3-300x48.png 300w\" sizes=\"(max-width: 693px) 100vw, 693px\" \/><\/figure>\n\n\n\n<p>In this case (Process-ID = 14256),  a docker image is using the port 8000.<\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4>Windows &#8211; Use Case<\/h4>\n\n\n\n<p><em><span class=\"has-inline-color has-vivid-cyan-blue-color\">PS: the command to get the process-ID for a program using a specific port is : <\/span><\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/for port 80\nnetstat -ano | findstr \/r 0.0:80\n\n\/\/for port XXX\nnetstat -ano | findstr \/r 0.0:XXX<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>the task could be stopped\/ended with :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ for port 80 in our case, because his PID is 4\ntaskkill \/pid 4 \/f<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h4>Linux &#8211; Use Case<\/h4>\n\n\n\n<p>To list any process listening to the port 8080:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lsof -i:8080<\/code><\/pre>\n\n\n\n<p>To kill any process listening to the port 8080:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kill -9 $(lsof -t -i:8080)<\/code><\/pre>\n\n\n\n<p>PS:  <code>-9<\/code>\u00a0corresponds to the\u00a0<code>SIGKILL - terminate immediately\/hard kill<\/code>. It implies the process will be killed forcefully.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let\u00b4s say , we want to find out which program is using the port 80 and 443 in our computer. (The port number started with 80 or 443) Enter the following at the prompt (cmd): In the last column, you can see the process ID. Here for example 4 for the port 80, and 14256 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[93,348,269,345,188,347],"_links":{"self":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1230"}],"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=1230"}],"version-history":[{"count":7,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1230\/revisions"}],"predecessor-version":[{"id":2283,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1230\/revisions\/2283"}],"wp:attachment":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}