[{"data":1,"prerenderedAt":280},["ShallowReactive",2],{"Categories":3,"NavIndexCategoriesCountFooter":203,"content-\u002F2018\u002F05\u002F31\u002Ffind-process-on-port-for-osx\u002F":204},[4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,68,70,71,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202],{"category":5},"System Administration",{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":27},"Software Development",{"category":5},{"category":5},{"category":5},{"category":5},{"category":27},{"category":27},{"category":5},{"category":5},{"category":5},{"category":27},{"category":5},{"category":5},{"category":5},{"category":27},{"category":27},{"category":27},{"category":27},{"category":5},{"category":5},{"category":5},{"category":27},{"category":27},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":27},{"category":5},{"category":5},{"category":27},{"category":27},{"category":27},{"category":27},{"category":5},{"category":27},{"category":27},{"category":67},"Drones & RC",{"category":69},"DIY Projects",{"category":67},{"category":72},"Photography",{"category":69},{"category":69},{"category":69},{"category":67},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":67},{"category":69},{"category":69},{"category":67},{"category":67},{"category":72},{"category":72},{"category":72},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":5},{"category":5},{"category":72},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":5},{"category":67},{"category":67},{"category":72},{"category":72},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":72},{"category":67},{"category":138},"3D Printing - Laser Cutting - CNC",{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":5},{"category":138},{"category":27},{"category":27},{"category":138},{"category":138},{"category":72},{"category":158},"Photography,3D Printing - Laser Cutting - CNC",{"category":27},{"category":27},{"category":69},{"category":27},{"category":27},{"category":27},{"category":27},{"category":5},{"category":67},{"category":5},{"category":5},{"category":27},{"category":27},{"category":27},{"category":27},{"category":27},{"category":69},{"category":27},{"category":27},{"category":27},{"category":27},{"category":181},"Home Assistant",{"category":181},{"category":72},{"category":27},{"category":27},{"category":72},{"category":138},{"category":5},{"category":72},{"category":72},{"category":138},{"category":27},{"category":181},{"category":181},{"category":72},{"category":72},{"category":72},{"category":72},{"category":72},{"category":72},{"category":72},{"category":72},191,{"id":205,"title":206,"body":207,"category":266,"date":267,"description":213,"embedImage":266,"extension":268,"image":266,"intro":269,"meta":270,"navigation":271,"path":272,"seo":273,"series":266,"sitemap":274,"stem":275,"tags":276,"__hash__":279},"content\u002F2018\u002F05\u002F31\u002Ffind-process-on-port-for-osx.md","Find process on port for OSX with lsof",{"type":208,"value":209,"toc":263},"minimark",[210,214,225,239,245,248,254,257],[211,212,213],"p",{},"It's often quite useful to know what running process is holding a port open. Doing this on linux has long been an easy case of running netstat with the -p option which shows the PID and name for each socket - for example:",[215,216,221],"pre",{"className":217,"code":219,"language":220},[218],"language-text","# netstat -lnp | grep :80\ntcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      14897\u002Fnginx.conf\n...\n","text",[222,223,219],"code",{"__ignoreMap":224},"",[211,226,227,228,238],{},"But the mac version of netstat doesn't support this option. I recently came across ",[229,230,237],"a",{"href":231,"rel":232,"target":236},"https:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F4421633\u002Fwho-is-listening-on-a-given-tcp-port-on-mac-os-x\u002F4421674#4421674",[233,234,235],"nofollow","noopener","noreferer","_blank","this post on stackoverflow"," that points out that you can use lsof:",[215,240,243],{"className":241,"code":242,"language":220},[218],"lsof -iTCP:xxxx | grep LISTEN\n",[222,244,242],{"__ignoreMap":224},[211,246,247],{},"and on later versions",[215,249,252],{"className":250,"code":251,"language":220},[218],"lsof -iTCP:xxxx -sTCP:LISTEN\n",[222,253,251],{"__ignoreMap":224},[211,255,256],{},"Note that this also works fine on linux:",[215,258,261],{"className":259,"code":260,"language":220},[218],"# lsof -iTCP:80 -sTCP:LISTEN\nCOMMAND   PID  USER   FD   TYPE    DEVICE SIZE\u002FOFF NODE NAME\nnginx   14897  root   48u  IPv4 525163059      0t0  TCP *:http (LISTEN)\n...\n",[222,262,260],{"__ignoreMap":224},{"title":224,"searchDepth":264,"depth":264,"links":265},2,[],null,"2018-05-31 08:25 +0200","md","netstat -p doesn't work on mac - let's find the same info via lsof",{},true,"\u002F2018\u002F05\u002F31\u002Ffind-process-on-port-for-osx",{"title":206,"description":213},{"loc":272},"2018\u002F05\u002F31\u002Ffind-process-on-port-for-osx",[277,278],"mac","linux","W78T97C1V4QLl21q0HlWabsjtx4FTpO_e_-HRYswFJk",1775293008095]