Tuesday, March 31, 2015

How to find which program is using which port in Windows

P
Sometimes you can't run your application because port conflict. Another process is using your port which is necessary for yours to start. Only way to solve this case is find out which process is using that port and kill it. This article will show you how to do that.
This sample below is find and kill a process is using port 80 and make my application cannot start.
SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-bio-80"]
java.net.BindException: Address already in use: JVM_Bind :80
        at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:411)
        at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:646)
        at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)
        at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:119)
        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:821)

Open cmd.exe and type:
netstat -aon | findstr :80

Output:

C:\Users\PHUONGVU>netstat -oan | findstr :80
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       4200
  TCP    0.0.0.0:8009           0.0.0.0:0              LISTENING       6496
  TCP    127.0.0.1:8005         0.0.0.0:0              LISTENING       6496
  TCP    [::]:8009              [::]:0                 LISTENING       6496
Now I find out that process has PID 4200 is using port 80. Now let open Windows Task Manager and kill it by clicking End task.
Done. Now I can start my application successfully.

No comments:

Post a Comment