解决python web项目意外关闭,但占用端口的问题
作者:ITAKEN''S PAGES 时间:2023-02-11 19:18:53
问题描述
因为项目强制关闭,但是服务还在运行,导致重新运行项目时候 提示地址已经使用(端口被占用)
/usr/bin/python3.5 python-login-demo/index.py
http://0.0.0.0:8080/
Traceback (most recent call last):
File "/var/www/git/mine/python-login-demo/index.py", line 64, in <module>
application.run()
File "/usr/local/lib/python3.5/dist-packages/web/application.py", line 341, in run
return wsgi.runwsgi(self.wsgifunc(*middleware))
File "/usr/local/lib/python3.5/dist-packages/web/wsgi.py", line 59, in runwsgi
return httpserver.runsimple(func, server_addr)
File "/usr/local/lib/python3.5/dist-packages/web/httpserver.py", line 177, in runsimple
server.start()
File "/usr/local/lib/python3.5/dist-packages/web/wsgiserver/wsgiserver3.py", line 1669, in start
raise socket.error(msg)
OSError: No socket could be created -- (('0.0.0.0', 8080): [Errno 98] Address already in use)
解决方法
查找(<strong>lsof</strong>)该进程, 并结束(<strong>kill</strong>)该进程 即可.
$ lsof -i:8080 130 ↵
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python3.5 31982 willike 3u IPv4 593966 0t0 TCP *:http-alt (LISTEN)
$ sudo kill 31982
来源:https://itaken.github.io/post/2017/07/28/python项目占用端口.html
标签:python,web项目,关闭,占用端口
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
利用JavaScript阻止表单提交的两种方法
2024-04-22 22:34:44
MySql中流程控制函数/统计函数/分组查询用法解析
2024-01-26 09:33:38
![](https://img.aspxhome.com/file/2023/9/105479_0s.png)
使用Filter过滤python中的日志输出的实现方法
2022-08-25 06:37:43
软件与网站设计的区别
2009-05-04 14:30:00
在Python的列表中利用remove()方法删除元素的教程
2023-03-21 12:42:39
IE7下动态创建Iframe时,去除边框的办法
2009-01-19 13:56:00
Python全栈之线程详解
2021-05-21 17:44:21
![](https://img.aspxhome.com/file/2023/4/101224_0s.png)
基于Go Int转string几种方式性能测试
2024-05-08 10:17:04
Go语言写入字符串到文件的方法
2024-05-21 10:21:54
vue3 $attrs和inheritAttrs的用法说明
2024-04-26 17:39:08
![](https://img.aspxhome.com/file/2023/3/133163_0s.png)
vue中v-model如何绑定多循环表达式实战案例
2024-04-09 10:59:42
![](https://img.aspxhome.com/file/2023/2/139722_0s.jpg)
Python Django2 model 查询介绍(条件、范围、模糊查询)
2023-11-02 15:32:09
MySQL InnoDB 锁的相关总结
2024-01-18 16:14:55
![](https://img.aspxhome.com/file/2023/3/82263_0s.png)
Python Pillow(PIL)库的用法详解
2022-01-31 13:43:26
![](https://img.aspxhome.com/file/2023/8/81458_0s.jpg)
.NET Core读取配置文件的方法
2024-06-05 09:31:38
基于标准的web项目开发模式探索
2013-12-12 15:05:25
![](https://img.aspxhome.com/file/UploadPic/20071/200713110544641s.gif)
ASP.NET Core MVC基础学习之局部视图(Partial Views)
2023-07-19 21:02:37
python使用ProjectQ生成量子算法指令集
2023-03-17 20:26:51
一个asp版的xheditor上传图片服务器端文件
2009-12-21 14:18:00
![](https://img.aspxhome.com/file/UploadPic/20101/11/200982514518-20s.jpg)
ASP中Cache技术的应用
2007-09-28 12:41:00