java 如何修复Tomcat启动失败:端口X已被使用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30836980/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix Tomcat has failed to start: the port X is already in used?
提问by Bic Mitchun
I'm trying to use a new installation of TomEEas a local server in Netbeans but i'm facing a weird issue. Everytime I try a port, it is in used. I tried many many ports but it is always in used. So I ran this command in command prompt:
我正在尝试使用新安装的TomEE作为 Netbeans 中的本地服务器,但我面临一个奇怪的问题。每次我尝试一个端口时,它都会被使用。我尝试了很多端口,但它总是被使用。所以我在命令提示符下运行了这个命令:
netstat -aon
netstat -aon
It listed all the listening ports with the PID. So I opened task manager and I found out that Java (TM) Platform SE Binary. I ended the process. Restarted Netbeans and everytime I end the java process, it seems it creates a new one not allowing me to use any port... Say I change it for another port, Java (TM) creates a new instance and uses the port I want to use throwing me a used port
error in the IDE.
它列出了所有带有 PID 的侦听端口。所以我打开了任务管理器,我发现了 Java (TM) Platform SE Binary。我结束了这个过程。重新启动 Netbeans,每次我结束 java 进程时,它似乎都会创建一个新的,不允许我使用任何端口......假设我将其更改为另一个端口,Java(TM)创建一个新实例并使用我想要的端口使用used port
在 IDE 中向我抛出错误。
How am I supposed to fix this if each single time I change port, Java creates a process and use the exact same port?
如果每次更改端口时,Java 都会创建一个进程并使用完全相同的端口,我应该如何解决这个问题?
回答by Sagar Pudi
Change the port number by editing the server.xml file in TomEE installation directory.
for example:
通过编辑 TomEE 安装目录中的 server.xml 文件来更改端口号。
例如:
<Connector port="18080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
回答by RajSharma
Yo have to chnage the port number. Follow these steps.
你必须更改端口号。跟着这些步骤。
1) Go to conf folder in tomcat installation directory e.g. C:\Tomcat 6.0\conf\
1) 进入 tomcat 安装目录下的 conf 文件夹,例如 C:\Tomcat 6.0\conf\
2) Edit following tag in server.xml file
2) 在 server.xml 文件中编辑以下标签
3) Change the port=8080 value to your desired value for ex- 8085
3) 将 port=8080 值更改为您想要的值,例如 8085
4) Save file.
4) 保存文件。
回答by Sarfaraz Khan
As per your description it looks like net beans is using your tomcat so when you restart after changing the port your netbeans starts the tomcat server internally then when you're trying to start another tomcat instance you'e getting the error.Your can check you netbeans setting to disable tomcat. Better to get a binary distribution of tomcat and run it with different port and try if its working.
根据您的描述,看起来 net bean 正在使用您的 tomcat,因此当您在更改端口后重新启动时,您的 netbeans 会在内部启动 tomcat 服务器,然后当您尝试启动另一个 tomcat 实例时,您会收到错误消息。您可以检查一下netbeans 设置以禁用 tomcat。最好获得 tomcat 的二进制发行版并使用不同的端口运行它并尝试它是否工作。