18

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.

Alexis Wilke
  • 2,697
  • 2
  • 19
  • 42
s.r
  • 341
  • 1
  • 2
  • 6

3 Answers3

8

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
1

I always use:

netstat -tupna

This way you won't miss anything.

Future
  • 179
  • 10
1

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.

Pedro
  • 1,821
  • 12
  • 23