Visit Our UNIX and Linux User Community

How to kill the TCP ESTABLISHED connection in netstat

Thread Tools Search this Thread
Operating Systems Solaris How to kill the TCP ESTABLISHED connection in netstat
# 1  
Old 11-19-2009
How to kill the TCP ESTABLISHED connection in netstat


Actually there are some bugs in application which does not close the TCP connection to other server though CORBA.

We need to kill that ESTABLISHED connections as new connection are not happeneing as the allocated ports were used and showing as ESTABLISHED

Is there any command in UNIX (sun solaris 5.9) to kill the connection that can seen while doing the following

netstat -an |grep <IP address>

I am unable to find the process which started the connection using ps -ef hecnce i cant use kill -9

please help

Unix beginer

Last edited by GIC1986; 11-19-2009 at 09:02 AM..
# 2  
Old 11-19-2009
The following command will show you all open files, including the TCP related ones, of all processes running on your system.
pfiles /proc/*

You should be able to easily locate the culprit from its output.

And by the way, please don't gratuitously run "kill -9", that's a poor practice.
# 3  
Old 11-19-2009
Jilliagre you are Brillant !!!

But now I dont know what to do with this out put i can see the connection but how i will kill (will not kill -9 Smilie ) /disconnect am not root in the server

I found out the culpritss by running under the application user in UNIX

Please suggest how i can disconnect these type of connections?? ( it counts more than 80)

Sample out put

 239: S_IFSOCK mode:0666 dev:315,0 ino:4352 uid:0 gid:0 size:0
        sockname: AF_INET <my IP>  port: 49389
        peername: AF_INET <destin IP>  port: 3955
 240: S_IFSOCK mode:0666 dev:315,0 ino:40669 uid:0 gid:0 size:0
        sockname: AF_INET <my IP>  port: 8103
        peername: AF_INET <destin IP>  port: 10008

Thanks in advance

Last edited by Neo; 11-19-2009 at 01:50 PM.. Reason: code tags please!
# 4  
Old 11-19-2009
You cannot kill connections but you can kill processes. The line you posted show file descriptors 240 and 239. Move back until you reach the first file descriptors open for this process, immediately before, you will find a line telling the maximum number of descriptors and then a line showing the process ID and the command line, just like in that example:

2917:   /usr/lib/firefox/firefox-bin
  Current rlimit: 512 file descriptors
   0: S_IFCHR mode:0666 dev:323,0 ino:6815752 uid:0 gid:3 rdev:13,2

I would run
kill 2917

# 5  
Old 11-20-2009
Thanks for the reply jlliagre,

Due the application urgency we are forced to go for the application (weblogic server restart to kill the connections ) then the connection status went to FIN_WAIT_1 from ESTABLISHED and later on it dissappered. Now BAU.

But the appplication bug is there so we may need to find out other than the application restart.

I followed the way you shown and i have find out the process but again it was the weblogic server running on the system. which means in order to kill the connection i need to kill/stop the weblogic server Smilie

But any way great learning !!

Thanks again for your patience in explaining this Smilie



Previous Thread | Next Thread
Test Your Knowledge in Computers #69
Difficulty: Easy
Grep stands for 'global regular expression process'.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

30 tcp connections Established for a while and after a few minutes are close

Good morning, I need your help please After Restarting Aps or connection, these are connections tcp 0 0 ESTABLISHED tcp 0 47 ESTABLISHED tcp 0 0 ... (4 Replies)
Discussion started by: alexcol
4 Replies

2. AIX

AIX firewall accept established connection

I'm trying to configure a firewall for AIX to accept incoming connections on ports 22 and 443 and deny everything else. All is ok; the server accepts connections only on 22 and 443, but after that I also need to accept all outgoing connections -- ssh and telnet, for example. So I started with ... (0 Replies)
Discussion started by: Michael1457
0 Replies

3. IP Networking

Need to know reason for connections closed in netstat -p tcp

Hello netstat -p give below 6634176 connections as closed.How do we trace that which all connections are being closed on the server? 1366888371 data packet headers correctly predicted 1195906 connection requests 5227320 connection accepts 5992919... (6 Replies)
Discussion started by: Vishal_dba
6 Replies

4. Red Hat

How to kill a TCP connection which has status TIME_WAIT & no PID

Hi, I want to kill TCP connections which have status as TIME_WAIT & no PID (as per the output of the "netstat - p" command). Is there any command/utility available to kill connections to a specific port or IP address. The problem is that these connections don't have process ID (see... (4 Replies)
Discussion started by: Davinder31may
4 Replies

5. Shell Programming and Scripting

Function to kill the established rsh session

HI I know that it sounds crazy :eek: appreciated if any one provided me a solution for my below case , the below script is checking the Database availability on many servers by establishing rsh session ( one by one ) , sometime one of the servers goes down and while this the script taking... (0 Replies)
Discussion started by: bejo4ever
0 Replies

6. UNIX for Dummies Questions & Answers

TCP failed connection attempts from netstat -s

Dear experts, I am seeing a lot of TCP failed connection attempts from "netstat -s" on one of our servers. How can I pin point what connection failed and what are the ports involved? Any tools/commands I can dig in deeper to diag. what went wrong on these "failed connection attempts"? ... (2 Replies)
Discussion started by: cache51
2 Replies

7. UNIX for Advanced & Expert Users

tunneling commands and file transfers through established ssh connection

Hi - I frequently run commands, and transfer files to/from a host that uses SecurID ssh authentication. It is a real pain to have to enter the authentication information every time I want to interact with this host. I am wondering if there is a way to establish a one-time ssh connection to this... (2 Replies)
Discussion started by: cpp6f
2 Replies

8. Red Hat

How to kill all active tcp connections from an IP?

How to kill all active tcp connections from an IP? I am using CentOS (3 Replies)
Discussion started by: an00p
3 Replies

9. UNIX for Dummies Questions & Answers

Query :: Using Netstat finding total value to a db connection

I wrote a very simple script to calculate the DB connection from an appserver and check the total netstat connection to a particular DB exceed 25 then it will send mail netstat -a 2> /dev/null | awk '/.*ESTAB/{print $5}' | cut -d. -f1 | uniq -c | awk '{if ($1 > 25)print $2," exceed ",$1;}' ... (1 Reply)
Discussion started by: senthil.ak
1 Replies

10. UNIX for Advanced & Expert Users

about TCP connection

Hi Experts, need help about release or refresh TCP Connection: i have the sample like below : application log connection: 0500 ( 00919 2007/05/10 23:30:25 112 13 2007/05/10 23:30:25 1969/12/31 17:00:00 0500 ( 00920 2007/05/10 23:30:26 000 00... (3 Replies)
Discussion started by: bucci
3 Replies

Featured Tech Videos