Debugging vicious java.net.BindException (Windows)

java.net.BindException is thrown when JVM fails binding a socket to a local address and port.. Most common reason is that port is already used by some other application/service. Message like “Port already in use: 1098;” further confirms this.

This is how you can debug this exception:

  1. Check which service is binding the port by command “netstat –b”

This will list down all port and the application which binds the port like:

Proto Local Address Foreign Address State PID

TCP hddlntd100000:1090 test.test.cim:1026 ESTABLISHED 2248 [OUTLOOK.EXE]

  1. Now check for the port which is shown as already in use. Like if the message resulted by BindException is “Port already in use: 1098”, then 1098 is in use by other application.
  2. Identify the application running on the given port. Like Outlook is acquiring port 1090.
  3. Either close the application which is acquiring the port directly by exiting the application like in case of Outlook or go to task manager and do end task for the given application/service. If application/service closes successfully you are done, now retry whatever had caused BindException earlier.

Related Post

Fiddler: Http debugging proxy
Start tomcat6 (installed as a windows service) debug mode using eclipse remote debugging
Simulating slow internet connection
Sun turns JavaScript into Java. Google turns Java into JavaScript

Comments

Leave a Reply




Technology