linux某端口被占用如何释放啊?
天蓬老师
天蓬老师 2017-04-17 17:08:57
0
4
1036

netstat -antp
lsof -i:5000

根本看不到进程id

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(4)
伊谢尔伦

Use the command to view

[root@web ~]# netstat -anp | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1652/nginx: master  
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      1377/httpd          
tcp        0      0 10.1.1.14:9300          10.1.1.18:59080         ESTABLISHED 1305/java           
tcp        0      0 127.0.0.1:49800         127.0.0.1:3306          ESTABLISHED 1715/zabbix_server: 
tcp        0      0 10.1.1.14:50480         10.1.1.17:10050         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:3306          127.0.0.1:49806         ESTABLISHED 1410/mysqld         
tcp        0      0 127.0.0.1:50280         127.0.0.1:3306          ESTABLISHED 1699/zabbix_server: 
tcp        0      0 127.0.0.1:3306          127.0.0.1:49800         ESTABLISHED 1410/mysqld         
tcp        0      0 127.0.0.1:3306          127.0.0.1:49804         ESTABLISHED 1410/mysqld         
tcp        0      0 10.1.1.14:33880         10.1.2.16:10050         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:49806         127.0.0.1:3306          ESTABLISHED 1711/zabbix_server: 
tcp        0      0 127.0.0.1:49808         127.0.0.1:3306          ESTABLISHED 1724/zabbix_server: 
tcp        0      0 10.1.1.14:36802         10.1.1.18:10050         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:49804         127.0.0.1:3306          ESTABLISHED 1708/zabbix_server: 
tcp        0      0 127.0.0.1:49802         127.0.0.1:3306          ESTABLISHED 1706/zabbix_server: 
tcp        0      0 10.1.1.14:54880         10.1.1.16:10050         TIME_WAIT   -                   
tcp        0      0 10.1.1.14:54808         10.1.1.16:10050         TIME_WAIT   -                   
tcp        0      0 127.0.0.1:3306          127.0.0.1:49808         ESTABLISHED 1410/mysqld         
tcp        0      0 127.0.0.1:3306          127.0.0.1:49802         ESTABLISHED 1410/mysqld         
tcp        0      0 127.0.0.1:3306          127.0.0.1:50280         ESTABLISHED 1410/mysqld         
raw        0    768 0.0.0.0:1               0.0.0.0:*               7           23580/fping        

For example: 1652/nginx: master, where "1652" is the PID and "nginx: master" is the program name.

Use the following command to kill:

[root@web ~]# kill -9 1652

If you know what program this is, it is recommended to use the program's own command to stop the service instead of rudely ending it with kill.

洪涛

The port is open because you have started the related service, you just need to turn off the service
Find the service and kill it or shut down

巴扎黑

This is because the system needs a certain amount of time to release the port. For example, when writing the flask service, if it is not set to DEBUG mode, CTRL+C will often be required. This will cause the 5000 port to not be released immediately. When the service is started again, it will report that the port is occupied. . If you write the socket service yourself, you can add a line of code to enable the system to release the port immediately after the service stops.

socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
大家讲道理

http://blog.csdn.net/cuiyong_... You can check this blog, it’s more detailed

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!