Command Line Tool to close a connection

Posted on 2004-09-08
Last Modified: 2010-04-11
I have what I hope is a simple question:

How can I close an unwanted tco/ip session from the command line?

I've been running the netstat tool to keep an eye on things, and occasionally I'll have a connection that I don't want but can't terminate.  Since it's not a file share, I don't know of any way to target the connection and cut it off.  Any ideas?
Question by:Zeek0
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 14

Expert Comment

ID: 12007784
What OS are you using?

Under linux:

type who to get the TTY the offending connection is using
<user>       pts/0    Sep  8 11:52
<user>       pts/1    Sep  8 11:52

type ps -ax to get running processes

31513 pts/1    S      0:00 -bash
31586 pts/0    S      0:00 -bash

as root type kill -9 <PID>

If pts/0 was the offending connection (using the above example) you'd type

kill -9 31586 (as root)

Hope this helps



Author Comment

ID: 12008195
Unfortunately, I'm asking about how to do it in XP.  It seems like an obvious task, but I haven't ever seen a way to do it - I'd prefer to use the command line, but any other strategies would be fine.
LVL 14

Expert Comment

ID: 12008352
Home or pro?
Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.


Author Comment

ID: 12008646
LVL 14

Accepted Solution

kenfcamp earned 50 total points
ID: 12008972
Do you generaly know the PID of the offending connection/service ?

If so try taskkill /PID <pid number>


Type tasklist to obtain a list of running processes
Locate the PID you're looking to kill
type taskkill /pid <pid number>

LVL 14

Expert Comment

ID: 12008996

To test this (play with it)

open 1 or 2 cmd consoles

as admin open a console and go to it..

NOTE: You will not be able to close down the cmd PID you're running the commands on


Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
During and after that shift to cloud, one area that still poses a struggle for many organizations is what to do with their department file shares.
After creating this article (, I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor ( Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month7 days, 5 hours left to enroll

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question