Search code examples
javaipserversocketportsinetaddress

Server Socket Error


i have got an error in this line:

new ServerSocket(2106, 50, InetAddress.getByName("83.4.200.1"));

Error log:

Exception in thread "main" java.net.BindException: Cannot assign requested address: JVM_Bind

83.4.200.1 is my ip, when i put there 127.0.0.1 or 192.168.1.2 with same port, everything is working perfect. I have checked all ports by writing netstat -a -n, but 2106 isnt there.

Thanks a lot for reading this, i hope that u can help me with my problem


Solution

  • Your routers address is 83.4.200.1. It's important to note that this isn't the address that your computer responds to, but rather the internal network address 192.168.1.2. If you want to connect to your program from outside the router, you needs to set up port forwarding for 2106 on the router.