端口
#0 GitHub
None
#1 环境
Mac
#2 需求分析
- 在mac上运行Django项目时,会遇到这种情况,当一个端口打开被django使用时(例如8888端口被Django使用),再次使用8888端口,就会提示该端口被占用,问题来了,如果8888端口已经使用了,但是如果pycharm的窗口被关掉了,就无法停止8888端口
如何关闭8888端口,重新运行web应用??
#3 开始
查看端口状态
ps aux | grep -i manage
cox 50409 1.2 1.0 299924 87892 ?? S 3:17下午 0:10.13 /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python /Users/cox/Documents/dianjing/manage.py runserver 0.0.0.0:8888
root 261 0.0 0.1 4332284 9512 ?? Ss 9:23上午 0:00.29 /usr/sbin/WirelessRadioManagerd
cox 260 0.0 0.1 4333668 6044 ?? S 9:23上午 0:00.22 /System/Library/CoreServices/backgroundtaskmanagementagent
root 125 0.0 0.1 4305220 5024 ?? Ss 9:22上午 0:00.30 aslmanager
cox 51003 0.0 0.0 4278260 824 s003 S+ 3:20下午 0:00.01 grep -i manage
cox 37688 0.0 0.2 282964 13744 ?? S 12:43下午 0:03.02 /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python /Users/cox/Documents/dianjing/manage.py runserver 0.0.0.0:8888
root 37554 0.0 0.1 4308280 5708 ?? Ss 12:42下午 0:00.05 /usr/libexec/diskmanagementd
关闭端口
kill -9 PID(第二列就是PID)