【Problems】端口被占用 查看是被谁占用并关闭它
经常在Windows、Linux环境下运行JavaWeb项目,Tomcat的端口被占用了。
端口被占用就查看是被谁占用关闭它就行。
Windows
在Windows上运行JavaWeb项目提示Tomcat端口被占用了。
Description:
The Tomcat connector configured to listen on port 8010 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector’s configuration, identify and stop any process that’s listening on port 8010, or configure this application to listen on another port.
查看某个端口被谁占用并强制关闭它。
打开cmd,输入netstat -ano
,列出所有端口的情况。观察被占用的端口,找到查看被占用端口对应的PID(一行的最后)。
或者直接输入命令+端口号:netstat -aon|findstr “8081”
回车查看到PID
我这里PID是76312。
输入tasklist|findstr “76312”
,回车,查看是哪个进程或者程序占用了8010端口的。
是java.exe,
可以打开任务管理器,在详细信息的PID一列查看76312对应的进程右键结束任务。
或者直接taskkill /pid 76312 -f
强制关闭。
小结:
netstat -aon|findstr “8081” 查看端口被谁占用的命令。
taskkill是Windows命令行里终止指定程序“进程”的命令。
taskkill /pid 76312 -f
taskkill /im java.exe -f
/f 表示强制终止
/im 表示指定的进程名称,例如“java.exe"
/pid 表示指定的进程ID进程号
Linux
运行个JavaWeb的程序。
java -jar school.jar
运行错误出现下面提示信息。
APPLICATION FAILED TO START
Description:
Web server failed to start. Port 8001 was already in use.
Action:
Identify and stop the process that’s listening on port 8001 or configure this application to listen on another port.
端口8001被占用了。。。应该是之前运行了。
[root@liuawen school]# netstat -anp | grep 8001
tcp 0 0 0.0.0.0:8001 0.0.0.0:* LISTEN 19453/java
[root@liuawen school]# kill -9 19453
[root@liuawen school]# netstat -anp | grep 8001
[root@liuawen school]# ps -ef | grep 8001
root 19625 19501 0 11:08 pts/2 00:00:00 grep --color=auto 8001
kill -9 进程号 杀掉占用端口的进程
最新文章
- Proj.4 API 中文参考
- mysql数据导出excel格式+乱码解决
- Log4jConfigListener cannot be found — context fails to start
- OC-block
- 怎样在mysql里面修改数据库名称
- C# 理解lock
- 了解下SoftReference
- OpenOffice 服务开机启动
- migrate from weblogic to tomcat: directory mapping--reference
- Python开发环境Wing IDE使用教程:部分调试功能介绍
- win7 64位wamp2.5无法启动MSVCR110.DLL丢失听语音
- MPLSVPN 命令集
- 同事搭一个测试RAC说节点2发现idle了,报ORA-00304
- python-shutil学习
- [Swift]LeetCode786. 第 K 个最小的素数分数 | K-th Smallest Prime Fraction
- 日志学习系列(三)——NLog基础知识
- PHP利用多进程处理任务
- 在Centos7上安装wxPython4.0.4
- Linux中的文件查找技巧
- CentOS6安装Zabbix4.0
热门文章
- webstorm2017.02版本如何使用material theme
- centos7下安装iostat命令
- 解决IDEA Maven下载依赖包速度慢问题
- Loading class `com.mysql.jdbc.Driver'. This is deprecated警告处理
- chrome 开发者工具使用一例
- 多任务-python实现-多进程文件拷贝器(2.1.10)
- angular8 大地老师学习笔记---第九课
- 前方高能!看Python程序员是表白的
- 数组单调性判断以及all和diff函数的用法
- python序列(六)列表排序