Freeing up a TCP/IP port?

2019-01-16 00:11发布

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

10条回答
再贱就再见
2楼-- · 2019-01-16 01:04

The "netstat --programs" command will give you the process information, assuming you're root. Then you will have to kill the "offending" process which may well start up again just to annoy you :-).

What are you actually trying to achieve here? Solutions will vary based on the processes holding those ports.

查看更多
甜甜的少女心
3楼-- · 2019-01-16 01:06

As the others have said, you'll have to kill all processes that are listening on that port. The easiest way to do that would be to use the fuser(1) command. For example, to see all of the processes listening for http requests on port 80 (run as root or use sudo):

# fuser 80/tcp

If you want to kill them, then just add the -k option.

查看更多
戒情不戒烟
4楼-- · 2019-01-16 01:09

sudo killall -9 "process name"

查看更多
女痞
5楼-- · 2019-01-16 01:10

Shutting down the computer always kills the process for me.

查看更多
登录 后发表回答