Freeing up a TCP/IP port?

前端 未结 11 1058
时光取名叫无心
时光取名叫无心 2020-12-07 06:59

netstat -tulnap shows me what ports are in use. How to free up a port in Linux?

相关标签:
11条回答
  • 2020-12-07 07:29

    To check all ports:

    netstat -lnp
    

    To close an open port:

    fuser -k port_no/tcp
    

    Example:

    fuser -k 8080/tcp
    

    In both cases you can use the sudo command if needed.

    0 讨论(0)
  • 2020-12-07 07:36

    You can use tcpkill (part of the dsniff package) to kill the connection that's on the port you need:

    sudo tcpkill -9 port PORT_NUMBER
    
    0 讨论(0)
  • 2020-12-07 07:37

    In terminal type :

    netstat -anp|grep "port_number"

    It will show the port details. Go to last column. It will be in this format . For example :- PID/java

    then execute :

    kill -9 PID. Worked on Centos5

    For MAC:

    lsof -n -i :'port-number' | grep LISTEN
    

    Sample Response :

    java   4744 (PID)  test  364u  IP0 asdasdasda   0t0  TCP *:port-number (LISTEN)
    

    and then execute :

    kill -9 PID 
    

    Worked on Macbook

    0 讨论(0)
  • 2020-12-07 07:42

    Shutting down the computer always kills the process for me.

    0 讨论(0)
  • 2020-12-07 07:44

    Kill the process that is listening to the port in question. I believe netstat shows you process ids.

    0 讨论(0)
提交回复
热议问题