Adrian Adamczyk Adrian Adamczyk - 2 months ago 23x
Java Question

Cannot assign requested address: JVM_Bind

When I'm trying to set up a socket server, I've got an error message:

Exception in thread "main" Cannot assign requested address: JVM_Bind
at Method)
at socketyserver.SocketyServer.main(
Java Result: 1

Whole 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?


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);


InetAddress locIP = InetAddress.getByName("");
serverSocket = new ServerSocket(9999, 0, locIP);

Of course replace with your actual IP address, or use