Tomcat修改80埠,埠被佔用,System佔用80埠問題解決

仲德明發表於2017-01-05

今天有些小小需求要使用Tomcat,將Tomcat修改為80埠,修改之後啟動Tomcat,報錯,提示埠被佔用。下面來看看問題怎麼解決

1、修改Tomcat埠號

開啟Tomcat安裝目錄,看到如下目錄




修改之後,儲存,開啟Tomcat。報錯,錯誤如下

嚴重: Failed to initialize end point associated with ProtocolHandler ["http-apr-80"]
java.lang.Exception: Socket bind failed: [730013] ???????????????í????×??????·??????×?
        at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:430)
        at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:640)
        at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)
        at org.apache.catalina.connector.Connector.initInternal(Connector.java:978)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:813)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:638)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:663)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:280)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:454)

一月 05, 2017 5:52:29 下午 org.apache.catalina.core.StandardService initInternal
嚴重: Failed to initialize connector [Connector[HTTP/1.1-80]]
org.apache.catalina.LifecycleException: Failed to initialize component [Connector[HTTP/1.1-80]]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
        at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:813)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:638)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:663)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:280)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:454)
Caused by: org.apache.catalina.LifecycleException: Protocol handler initialization failed
        at org.apache.catalina.connector.Connector.initInternal(Connector.java:980)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        ... 12 more
Caused by: java.lang.Exception: Socket bind failed: [730013] ???????????????í????×??????·??????×?
        at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:430)
        at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:640)
        at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)
        at org.apache.catalina.connector.Connector.initInternal(Connector.java:978)
        ... 13 more
這就是說我們修改的80埠被佔用了。

因為我電腦上裝有IIS伺服器 ,他的預設埠是80,就想著把IIS伺服器停掉,開啟IIS伺服器找到最上面節點,右鍵停止

再次啟動Tomcat,發現還是不行,好吧,開啟伺服器管理,找到IIS Admin Service服務,停止掉



再次重啟Tomcat,還不行,今天上帝和耶穌打牌去了吧。。。。

好吧,開啟命令列輸入命令netstat -oan|find "80"


發現80埠被PID為4的哥們佔用,好吧接著找,在命令列輸入tasklist|find "4"


哎喲,我去被System佔用了,不會吧

接著找吧,在命令列輸入netsh http show servicestate


恍然大悟,原來是SQL服務,立馬的,幹掉他。

重啟Tomcat,在瀏覽器位址列輸入127.0.0.1 測試出現Tom貓OK,解決



相關文章