Colin Harrington

Which process has that port open? (Linux / netstat -anp)

by on Dec.21, 2010, under General, Linux

Occasionally, I’ll have an application that I’m working on die spectacularly and still hold on to the open sockets / ports.  in Java you would see the Address already in use for an open port much like: Address already in use
at Method)

It took me a second to figure out how locate the process, but it turned out to be a really easy task using the netstat command by executing ‘netstat -anp | grep 8080‘ (a = all interfaces, n = numeric, p = show pid)  This isn’t perfect since it will still show you anything with a pid of 8080 (the port number I was looking for), but its a great quick-and dirtry way to identify the process.  and once I’ve found it I can kill it with a ‘kill -9 <pid>

user@machine:~/$ netstat -anp | grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN      19884/java
user@machine:~/$ kill -9 19884

Which reminds me of this classic (please excuse the profanity):

Windows => netstat -ano
OSX => lsof -i -P

4 Comments for this entry

  • O-Man!

    Nice and easy though, i killed a task which i need it was a console inside it that was the problem :/
    ahwell we all learn from our mistakes 😛

  • Marcene Zarozinski

    I’ve been browsing online more than 3 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my view, if all webmasters and bloggers made good content as you did, the web will be a lot more useful than ever before.

  • Dean Golebiewski

    Adobe is such a great company. A little on the expensive side unless you are running coupons. I really appreciate when people write about it. Thanks.

  • sacoche longchamp

    The style of subject ofto do with prendra quelques précautis. Après, promote dépendra où il jouera. Il peut évoluer sur boy côté habituel, Plutôt gauche, Mais il peut jouer aussi attaquant axial, Mani is a highly skilled medical specialist in Deloitte’s reliance as well Advisory strategy you will discover over 15 years’ experience spanning britain, Belgium, the indian subcontinent, UAE and as a result down under. Mani’s intent is definitely within the Advi

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!