How to close a unix port

I have an issue with port 7331 on our Unix box that is hung, It is stuck in a listen status:

ukh-o2-jcaps1:/tstjcaps6/apptest2> netstat -a|grep 7331
tcp4    1019      0  ukh-o2-jcaps1.7331     10.230.6.7.59010       CLOSE_WAIT
tcp4    1019      0  ukh-o2-jcaps1.7331     10.230.6.7.59215       CLOSE_WAIT
tcp4    1019      0  ukh-o2-jcaps1.7331     10.230.6.7.59459       CLOSE_WAIT
tcp4    1019      0  ukh-o2-jcaps1.7331     10.230.6.7.59668       CLOSE_WAIT
tcp4    1019      0  ukh-o2-jcaps1.7331     10.230.6.7.59912       CLOSE_WAIT
tcp4    1019      0  ukh-o2-jcaps1.7331     10.230.6.7.60130       CLOSE_WAIT
tcp4    1019      0  ukh-o2-jcaps1.7331     10.230.6.7.60361       CLOSE_WAIT
tcp4    1019      0  ukh-o2-jcaps1.7331     10.230.6.7.60578       CLOSE_WAIT
tcp        0      0  *.7331                 *.*                    LISTEN

the lsof shows no PID id is using it. Nothing is displayed. It looks like it is stuck and we need to close it. How do we force close a port w/o a PID process is using it? Thanks

I have always been able to find a process doing a listen. Are you running lsof as root? Did you use lsof -i :7331 ? Also what OS are you using?

Not in this case. we have non displayed for this port. We fixed the issue by rebooting the server, but there got to be a quicker way to close a runaway port / orphan port. it is AIX VER 5.3. tl11 sp4

Try these..

 netstat --tcp --udp --listening --program 

or

 fuser -v 7331/tcp 

That should tell you what program is associated with the port.

This should all tell you a bit more and now you can kill it.

 fuser -vk 7331/tcp 

when i run fuser -v 7331/tcp i get this error:

fuser: Not a recognized flag: v
Illegal option ignored.
7331/tcp: A file or directory in the path name does not exist.

Those options work in Linux. This is not exactly a shell scripting issue. I am going to move this thread to the AIX forum. Maybe the AIX experts can help you out.

any takers please?

Hi,

netstat -Aan | grep 7331
The hex number in the first column is the address of protocol control block (PCB)

rmsock <addr of PCB> tcpcb This shows the process ID that is using the socket

Once you kill the process, the listening stops.

Regards
zxmaus