Question

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

Was it helpful?

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.

OTHER TIPS

1. If you want to access this Server with IP: "83.4.200.1" through Internet, then it must be your static ip, rather than an dynamic one.

2. Try to run this code with a private ip address or public ip address which is assigned to your pc in LAN (ie. Without internet..JUST WITH WIRELESS CONNECTION).

3. Private ip or Public ip has No meaning until and unless you are on INTERNET.. TILL THEN YOU CAN USE BOTH, AS ITS LAN.

4. Private ip ranges

Class A : 10.0.0.0 - 10.0.0.255 Class B : 172.16.0.0 - 172.31.255.255 Class C : 192.168.0.0 - 192.168.255.255

5. Public is given by your service provider, which will be anyone OUT of the private ip range. If your ip is not static, there is hardly or none of your chances to access the server over internet, there are sites that gives static ip out of your dynamic ips.

83.4.200.1 is my ip

It is the IP address of your router.

It isn't an IP address of the host you are running your code in, so you can't bind to it. You need to bind to a local address of that host, and arrange port forwarding from the router to your host. Most usually the bind-address is best omitted altogether, just specifying a port, in which case the socket will listen on all local IP addresses.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top