1

After starting an HTTP server process a couple of times, I get this error like an instance of Go has not stopped!?

listen tcp :9000: bind: address already in use

I have experienced something like this with Node.js too, but I was able to kill the process.. Unfortunately it seems like I can't find the process id and kill it..

How can I "free" the TCP port?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
clarkk
  • 27,151
  • 72
  • 200
  • 340

1 Answers1

5

If you are on Unix-like system, you can use netstat to find out which process is listening on a port:

sudo netstat -nlp | grep 9000

It turns out the -p option is not available on OS X. If you are using OS X, you can do this:

lsof -n -i4TCP:$PORT | grep LISTEN

Who is listening on a given TCP port on Mac OS X?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
bhspencer
  • 13,086
  • 5
  • 35
  • 44