Kernel thinks tcp port in use but isnt

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Kernel thinks tcp port in use but isnt
# 1  
Old 01-17-2012
Kernel thinks tcp port in use but isnt

I have a RHEL 5.5 system that i see this behavior on:

# uname -a
Linux myhost 2.6.18-194.17.4.0.1.el5 #1 SMP Tue Oct 26 20:10:33 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

#using netcat to listen to a port tells me its in use.
$ nc -l myhostip 33371
nc: Address already in use
$

# trying to telnet to the port
$ telnet myhostip 33371
Trying myhostip...
telnet: connect to address myhostip: Connection refused
telnet: Unable to connect to remote host: Connection refused

# lsof doesn't agree. returns nothing
$ lsof | grep 33371
$

# another option to lsof thats supposed to find sockets. returns nothing.
$ lsof -i :33371
$

# netstat -an doesn't show the port listening or in time_wait or in close_wait state.
$ netstat -an | grep 33371
$

Anyone have any idea on how to figure out what is using that port? I don't want to just reboot to fix.
# 2  
Old 01-18-2012
I don't suppose you're using selinux?
# 3  
Old 01-18-2012
no not using selinux...
# 4  
Old 01-19-2012
a colleague of mine used system tap to track the inet_csk_bind_conflict function and found that "nscd" process was the one hanging on to the tcp port.

this is what the system tap trace looked like:

inet_bind(nc): socket [state 1 type 1] uaddr 0.0.0.0:23426 addr_len 16
tcp_v4_get_port(nc): sock [reuse 1 state 7] snum 33371
bind_conflict(nc): sock [reuse 1 state 7] tb [port 33371 fastreuse 0 (reuse 0 state 7 owner (pid 0 uid 0 euid 0) uid 28 gid 28)]
bind_conflict: return 1 (EPERM)
tcp_v4_get_port: return 1 (EPERM)
inet_bind: return -98 (EADDRINUSE)

$ getent passwd 28
nscd:x:28:28:NSCD Daemon:/:/sbin/nologin

Restarting nscd freed up the port.

Anyway, 2 morals to the story:
1) I have some wicked smart colleagues.
2) when in doubt, restart nscd!
# 5  
Old 01-24-2012
To find out what's using the port type:
Code:
lsof -i :(your-port-number-here-without-parens)

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

Tcp ip port open but no such process (merged: Release A Port)

i want to kill a tcp connection by killing its pid with netstat -an i got the tcp ip connection on port 5914 but when i type ps -a or ps-e there is not such process running on port 5914 is it possible that because i do not log on with proper user account i can not see that process running? (30 Replies)
Discussion started by: alinamadchian
30 Replies

2. UNIX for Advanced & Expert Users

TCP Kernel Settings

I have solaris 9 system. I want to change the "tcp_conn_req_max_q" setting in /etc/system. whats the correct way, set ndd:tcp_conn_req_max_q=2048 or set tcp:tcp_conn_req_max_q=2048 thanks (1 Reply)
Discussion started by: chaandana
1 Replies

3. Programming

Using socket to test a TCP port

Hello, I'm trying to write a small c application to test a tcp port. This works fine for the most part but the default timeout on the connect is very long. I have been reading many posts but and it looks like I need to set the socket to be non-blocking and poll for a result. I have been totally... (2 Replies)
Discussion started by: tjones1105
2 Replies

4. IP Networking

TCP port numbers reused

Hello all, I am loosing the diameter connection between two servers and when the connection is trying to comes up again i see the following message in the tracer. and after 1 second the connection resets. As far i know the connection stay in state TIME_WAIT for a while(60 seconds in my... (1 Reply)
Discussion started by: @dagio
1 Replies

5. Programming

Getting TCP Port status through C API

Does anyone know if there is a C API call to get the status of a TCP port? As opposed to running netstat and parsing the results. At the moment I have to attempt to bind() and pick up on the address in use error which isn't very elegant Thanks ---------- Post updated at 10:42 AM ----------... (0 Replies)
Discussion started by: janra
0 Replies

6. Shell Programming and Scripting

TCP port assignment

I have multiple processes running the same program on my linux machine. For each process I want to be able to use a unique (available) TCP port. I have thought of using netstat to check which ports are available for use however, the time-window between checking and selecting might expose some race... (1 Reply)
Discussion started by: timmylita
1 Replies

7. UNIX for Dummies Questions & Answers

close tcp port

Hello, I have a service running (ODBC) and every now and then it will hang and I will have to stop and restart the service. The problem is when I stop the service, it indeed stops the service, but netstat reports a tcp port still open with the fin_wait_2 status. Then I must close the client... (1 Reply)
Discussion started by: raidzero
1 Replies

8. UNIX for Dummies Questions & Answers

restrict tcp-port access

Hi Is there any way to restrict the TCP-IP port usage. I want to restrict TCP-IP port 1500/1550 to the oracle osuser. Tanks in advance. Remi (2 Replies)
Discussion started by: remivisser
2 Replies

9. UNIX for Dummies Questions & Answers

Redirecting output to TCP port

Hi All, I suspect this is simple but I cannot find any info on it. I have a logfile on a solaris box (EMS) that I want to tail -f but I want the output of this to be redirected to a TCP port. I have a second solaris box (PEM) running patrol enterprise manager that I am using as an alarm... (1 Reply)
Discussion started by: mscomms
1 Replies

10. IP Networking

tcp problem with port

I am trying to connect via DBACCESS and Informix server to a server on a different computer. When I execute the connect command from dbaccess I get the following message, Exec format error cannot bind a name to the port. As far as I know the port is not being used by another client. How... (1 Reply)
Discussion started by: lopez
1 Replies
Login or Register to Ask a Question