Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I ended up in situation with a TCP port in listen mode with no process assigned to it.

Is there a way to close this port without restarting server?

Checking port status:

me> netstat -tan | grep 8888
tcp        0      0 :::8888                :::*                    LISTEN

Looking for process responsible:

me> lsof -i -P | grep 8888

Above command returns nothing

share|improve this question
    
service networking restart ? –  SpacemanSpiff Jul 15 '11 at 16:34
    
Do you have zombie procs open? You seem to know which process opened the port. Maybe you should run ps -ef to grep for the process in question, then kill its parent PID. –  Jodie C Jul 16 '11 at 15:26
add comment

4 Answers

Try netstat -ltpn | grep 8888

share|improve this answer
2  
also look at rpcinfo -p –  Jodie C Jul 15 '11 at 17:02
    
_______ Also not –  poige Jul 15 '11 at 17:09
    
As well what do you mean? –  Jodie C Jul 15 '11 at 20:25
    
I meant that netstat is enough to answer to original question. –  poige Jul 16 '11 at 2:54
1  
@Jodie C, I've installed NFS utils, and I should admit you were right — I see [nfsd] running in kernel mode, and there're several TCP ports w/o indicated owner in netstat's output. So, you were right, rpcinfo -p is worth noting as well. Thanks :-) –  poige Jul 16 '11 at 14:46
show 5 more comments

run a

fuser 8888/tcp

That should list pids running on the port.

share|improve this answer
    
Run it, returns no output. –  jarekrozanski Jul 16 '11 at 9:54
add comment

You are describing an impossible scenario.

I believe what the previous posters are missing is the fact that you are trying to map a port to a process which you do not own. Therefore your lsof returns nothing since those tools do not have permission view the /proc entries that would facilitate that port -> PID mapping. Your netstat command is lacking a -p flag as well. Run those commands as root then things will be much clearer.

share|improve this answer
    
I am the owner of the process. Do I need to be the root to find my own process? –  jarekrozanski Jul 16 '11 at 9:55
    
You do not need to be root to see your own processes. You can prove my theory wrong by running sudo netstat -antp | grep 8888 and posting the output. Then we can stop guessing at what the problem is. –  loopforever Jul 16 '11 at 11:26
add comment

netstat does parse /proc/net/[tcp|udp|tcp6|udp6] and then scans the /proc/$pid/-area to find matching processes, while fuser and lsof do "only" travel through the whole /proc/$pid/-area to find which processes are known for which sockets. Ultimately, those two different approaches may end in different results.

If there is no process assigned to the socket, there are two options:

  • You're using lsof/fuser and there is no process allocating this socket, but e.g. a kernel module is doing so. You need to find that module.
  • you're running netstat as an user who may not access /proc/$pid/fd/.

For example, mounting a share via NFS does result in similar "listening" ports. So those ports will re-appear by mounting a NFS share and will disappear after unmounting the NFS share.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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