{"id":195,"date":"2015-11-12T10:10:42","date_gmt":"2015-11-12T08:10:42","guid":{"rendered":"https:\/\/www.nonamehosts.com\/blog\/?p=195"},"modified":"2015-11-12T10:10:42","modified_gmt":"2015-11-12T08:10:42","slug":"how-to-find-pid-of-a-process-listening-on-port","status":"publish","type":"post","link":"https:\/\/www.nonamehosts.com\/blog\/readings\/how-to-find-pid-of-a-process-listening-on-port\/","title":{"rendered":"How to find PID of a process listening on port?"},"content":{"rendered":"<p style=\"text-align: justify;\">In Linux, many times, you want to find out the PID of a process which is\u00a0listening on a port e.g. if multiple apache(httpd)\u00a0servers are running on a host then, how do you find the PID of the apache(httpd) listening on port 8080?<\/p>\n<p style=\"text-align: justify;\"><!--more--><\/p>\n<p style=\"text-align: justify;\">Here are few\u00a0examples how to do that:<\/p>\n<p style=\"text-align: justify;\">1. to find the PID of your httpd\u00a0server listening on port 443, you can use following UNIX command:<\/p>\n<pre class=\"lang:sh decode:true\"># netstat -anp |grep 443\ntcp 0 0 :::443 :::* LISTEN <strong>1147<\/strong>\/httpd<\/pre>\n<p>ps.\u00a0(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)<\/p>\n<p>From the output above we can see that process running on port 443 is httpd and PID: 1147<\/p>\n<p>2. Another\u00a0example of lsof command to list the process listening on a port.<\/p>\n<pre class=\"lang:sh decode:true \"># lsof -i :443\nCOMMAND PID USER FD TYPE DEVICE SIZE\/OFF NODE NAME\nhttpd <strong>1147<\/strong> apache 6u IPv6 5021617 0t0 TCP *:https (LISTEN)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In Linux, many times, you want to find out the PID of a process which is\u00a0listening on a port e.g. if multiple apache(httpd)\u00a0servers are running on a host then, how do you find the PID of the apache(httpd) listening on port 8080?<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,5],"tags":[68,71,84,116],"class_list":["post-195","post","type-post","status-publish","format-standard","hentry","category-readings","category-tutorials","tag-linux","tag-lsof","tag-netstat","tag-servers"],"_links":{"self":[{"href":"https:\/\/www.nonamehosts.com\/blog\/wp-json\/wp\/v2\/posts\/195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nonamehosts.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nonamehosts.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nonamehosts.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nonamehosts.com\/blog\/wp-json\/wp\/v2\/comments?post=195"}],"version-history":[{"count":0,"href":"https:\/\/www.nonamehosts.com\/blog\/wp-json\/wp\/v2\/posts\/195\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nonamehosts.com\/blog\/wp-json\/wp\/v2\/media?parent=195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nonamehosts.com\/blog\/wp-json\/wp\/v2\/categories?post=195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nonamehosts.com\/blog\/wp-json\/wp\/v2\/tags?post=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}