10

In what scenarios port being used by a process don't show up in netstat -a output.

I'm running jenkins on my machine. It's listening on port 8080. I'm trying to start another process that tries to bind on same port and it fails with error that port is already in use.

Now when I do netstat -a | grep 8080, it doesn't show up in output. After stopping jenkins my process successfully bound to 8080. Any clues what happening?

I'm running CentOS.

  • 1
    Try netstat -lp, showing you processes that are listening. – sr_ Jul 21 '14 at 11:11
  • 6
    Try also netstat -an | grep 8080, in case 8080 is in your /etc/services file and is being replaced by its symbolic name. – Flup Jul 21 '14 at 11:24
  • 2
    Another approach would be using lsof -i :8080 – Valentin Bajrami Jul 21 '14 at 13:20
  • 1
    both netstat -an and lsof -i :8080 worked.. Thanks for your help!!! – r.s Jul 22 '14 at 2:05
  • You port is probably showing up by name rather than number. Uset netstat -an – user132698 Sep 4 '15 at 14:24
4

Just had a similar case on Ubuntu 14.04. Indeed jenkins default port (8080) is mapped to "http-alt" name in /etc/services. You can easily check this with

grep 8080 /etc/services
http-alt    8080/tcp    webcache    # WWW caching service
http-alt    8080/udp

In addition to netstat you can consider using ss

ss -ntl | grep 8080

or

ss -tl | grep http-alt
0

I always use:

netstat -tupna

This way you won't miss anything.

0

In what scenarios port being used by a process don't show up in netstat -a output.

If everything is working correctly, never. As mentioned above, you could have your port number replaced by the service name as listed in /etc/services.

Using netstat -na ensures service ports are not translated to service names.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.