1

I have been trying to connect to my own Java TCP application, which is running on a rented server with static public IP.

Scenarios that work:

  • server runs host app, and servers from https://check-host.net/ connect to it.
  • [my] PC runs both host and client app and connects them.

Scenarios that do not work:

  • server runs host app and [my] PC tries to connect (w\ client app, PowerShell Test-NetConnection, CMD telnet)
  • [my] PC runs host app and the server tries to connect with client app.

Additional details:

  • The server and my PC are able to ping each other.
  • I have tried disabling windows firewall, but to no avail.
  • My PC is connected to the internet via a modem (I am unfamiliar with modem limitations)
  • Java throws the IOExeption: "java.net.BindException: Cannot assign requested address: bind" when trying to start the host application on my PC with it's current public IP specified as the bind address. (The rented server does the same procedure without issue)

[No longer true] I will leave the server running, for those who want to try and connect: IP = **.***.***.** Port = 25 Protocol = TCP (If a successful connection is made from someone at home, then I at least know the issue is local)

I am at a complete loss, and hope that I am giving sufficient information to hint at what is going wrong. I appreciate all feedback as to what could be going wrong.

Thanks in advance.

5
  • 1
    Your PC does not have your public IP address. Your router does.
    – Daniel B
    Mar 29, 2022 at 5:03
  • 1
    Many, probably most, residential and consumer ISPs block or intercept outgoing. and sometimes incoming, TCP port 25 (allocated to SMTP) because 99.9999% of that traffic is spam, fraud and malware from devices 'pwned' by criminals. If you want SMTP, try 587 with authentication (and preferably starttls) instead. If you want something else, don't use 25. Mar 29, 2022 at 5:47
  • On your PC: a modem per se doesn't give you internet functionality. Usually, you establish a PPPoE connection directly on the computer or you are using a router. How is the connection established?
    – Albin
    Mar 29, 2022 at 10:25
  • Also the set setup is a little unclear, could you describe it (a diagram would work best) before you describe the scenarios?
    – Albin
    Mar 29, 2022 at 10:27
  • @MJSD Just wanted to let you know that the IP that you have censored is still visible in the edit history. You need to contact a moderator to have the edit history redacted. Jun 22, 2023 at 11:20

2 Answers 2

0

So, your problem is actually primarily this:

java.net.BindException: Cannot assign requested address: bind

It means the program did not start correctly. You would not be able to connect to it from remote or local devices.

There are two possibilities why it’s not working on your PC. First, binding to ports under 1024 is a privileged operation on most operating systems. You need admin rights to do it. You’re trying to bind to port 25.

Then, the “obvious” problem: Your PC probably does not actually have your public IP address. Connecting directly to the internet (without a router) is exceedingly rare today. Instead, a router has the public IP address. Your “modem” is probably actually a router. Or maybe you’re behind Carrier-grade NAT (CGNAT). That would leave you unable to accept incoming connections.

On your PC, you must use its local IP address (something like 192.168.123.123). On your router, you must set up port forwarding.

dave_thompson_085 also raises a valid port about port 25 (SMTP) specifically: Due to the spammy nature of traffic on this ports, many ISPs have it blocked, even if they otherwise allow incoming connections.

0

With the information that the comments and @DanielB gave me, I was able to solve the issue.

  • Firstly: I changed the port to a number above 1024 (Don't know if that contributed, but did it to be safe).
  • Secondly: I went on my ISP's website, and enabled port forwarding for my newly chosen port.

Now the application connects fine both ways. Although I also learned that I am to host with my local IP on my PC, but connect to the PC's public IP from the server.

Thanks for all the input! I wouldn't have been able to solve the issue this quickly without it.

1
  • (based on the comments) When using a router rather than a modem, you'd probably have to enable port forwarding on the router, rather than the ISP's website. My particular case involved a modem.
    – MJSD
    Mar 30, 2022 at 15:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .