Networking – How to make a server accessible over the internet

javajavascriptnetworkingport-forwarding

I wrote a chat client and server in Java. It works but as I'm finding out, only locally. The goal is to get it to function over the web.

I've tried quite a lot of things, and can elaborate if need be. Completely new to this, so figure I'm suffering from a lot from "Don't know what I don't know" here."

This is what I've done so far:

  • Enabled port-forwarding on my router.
  • Ensured a static local IP address.
  • Added the service on my network, with the proper port.
  • Added an inbound rule that allows it through windows firewall, and though I'm not sure it was necessary, to cover my bases, I also added an outbound rule to match.
  • Utilized http://www.canyouseeme.org/ to make sure that my service is reachable.

There was a similar question to this on SO, but it's for a web server and deals with .

Best Answer

You need to ensure the routing path is complete from internet machines to your desktop. For this to work you need to remove all port blocks (firewalls) for the ports you are interested in exposing, and also ensuring that trafic is routed from your public IP address to the server's IP (if the server is private).

This is normally all accomplished on your home router/wifi/modem box which performs the Network Address Translation (NAT) service for your home network (pretends to be your internal computers when your computers talk to the internet)

So, you need to:

  • in your router, configure the firewall to allow the specific port your server uses (say port 4321).
  • in your router, configure a port-forward for the port 4321 to the internal IP address of your actual server, also to port 4321.
  • on your server, ensure your firewall allows connections to port 4321

Test your chat clients work internally on your network (no NAT involved). Then, test your remote clients work by connecting to your public IP address, on the port you forwarded.

Related Question