Linux: How to kill programs that use port 1935?

yarek picture yarek · Oct 16, 2010 · Viewed 25.1k times · Source

I have a red5 server (JAVA) running on my Linux server.

Sometimes, the server shuts down. When I try to restart it I got an error:

"Binding error, this port is alerady in use".

So I try to kill the server with killall -9 java and try to restart the server: same error.

I have to wait for a while (about 2-3 minutes) and restart it again: that works.

I just need to know why when I kill the process I still have to wait 2-3 minutes before port 1935 is free and I can run the server again.

Is there a way to kill this process immediately and free the port ?

Answer

Nikita Rybak picture Nikita Rybak · Oct 16, 2010

If you're sure old instance of your server holds the port, just run jps, find your server pid in the list and run kill -9 my_pid

For generic non-java process, lsof -i :1935 usually works for me. Again, take pid and kill this process.