Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I used to do this in the Windows world with tool called TCPView: just select a established connection (ESTABLISHED), then select "Close Connection". I can't find a way to this on Mac OSX or Linux (I need both). The only way I know of is to kill the process that has the port open.

My main use case is to simulate interruptions in connectivity to test failover, like unplugging a cable or losing a router or middleware situations.

share|improve this question
Killing the process is not good enough? – terdon Feb 26 '13 at 14:28
up vote 1 down vote accepted

You could attach to your process using gdb and close() the file descriptor corresponding to the connection. You can find out the file descriptor number using lsof -a -i4 -p $PID.

share|improve this answer
works! too bad gdb pauses the program, but I'll look more into that – Rodrigo Gonzalez Feb 26 '13 at 19:52
  • tcpkill -i eth0 { expression }
    (basic command/options)

  • tcpkill -i eth0 port 21
    (Kill all outgoing ftp (port 21) connection)

  • tcpkill host
    tcpkill host
    (Kill all all packets arriving at or departing from host

  • tcpkill ip host and not
    (To kill all IP packets between and any host except

share|improve this answer

Your Answer


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.