Exception in thread "main" java.net.BindException: Cannot assign requested address: JVM_Bind at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383) at java.net.ServerSocket.bind(ServerSocket.java:328) at java.net.ServerSocket.(ServerSocket.java:194) at java.net.ServerSocket.(ServerSocket.java:106) at socketyserver.SocketyServer.main(SocketyServer.java:12)Java Result: 1Whole code is simplest as it can be:

public static void main(String<> args) throws UnknownHostException, IOException{ ServerSocket serverSocket; serverSocket = new ServerSocket(9999);}I"m 100% sure that my ports are forwarded, Windows Firewall is off. Nothing blocks port 9999. What else can go wrong?




You are watching: Java.net.bindexception: cannot assign requested address: bind

*

*

It may be related to a misconfiguration in your /etc/hosts.In my case, it was like this:192.168.1.11 localhost instead of 127.0.0.1 localhost


*

As other people have pointed out, it is most likely related to another process using port 9999. On Windows, run the command:

netstat -a -n | grep "LIST"And it should list anything there that"s hogging the port. Of course you"ll then have to go and manually kill those programs in Task Manager. If this still doesn"t work, replace the line:

serverSocket = new ServerSocket(9999);With:

InetAddress locIP = InetAddress.getByName("192.168.1.20");serverSocket = new ServerSocket(9999, 0, locIP);Of course replace 192.168.1.20 with your actual IP address, or use 127.0.0.1.


*

*



See more: Ted And Blake Queer As Folk Play In Rent? (Message Board) Dean Armstrong

Just for others who may look at this answer in the hope of solving a similar problem, I got a similar message because my ip address changed.

java.net.BindException: Cannot assign requested address: bind at sun.nio.ch.Net.bind(Native Method) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:126) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59) at org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:182) at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:311) at org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:260) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59) at org.eclipse.jetty.server.Server.doStart(Server.java:273) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)