Ubuntu – can’t open port

networkingport-forwardingrouter

I'm new in ubuntu & networking.

I opened port: 9876 ofr tcp and udp.
I Created a java udp client and server. The server is listening to port 9876 and I connected to my server with my external ip adress.
After I opened the port menually in my home router (see image), my udp client-server is working great.

enter image description here

My problem:

When I check if port 9876 is open in my machine from this site: https://www.yougetsignal.com/tools/open-ports/ , it say it's closed.
Why? (even when I'm running the udp server which listen to this port).
How can I open port 9876 in my machine to everyone in the internet?


Commands I run in my local machine:

stavalfi@laptop:~/IdeaProjects/torrentx$ netstat -tulnp | grep 9876
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
stavalfi@laptop:~/IdeaProjects/torrentx(stav)$ sudo ufw status verbose
Status: inactive
stavalfi@laptop:~/IdeaProjects/torrentx(stav)$ sudo ufw status
Status: inactive

If I understood currectrly, My firewall in my machine is off and port 9876 is not open.

Best Answer

There are three things to check:

  • Your local machine's port
  • Your local machine's firewall
  • Your router

Some of these steps you have probably already done. Do them again in order, to eliminate each possible issue methodically. Don't jump around.

Local Machine Port: Be sure the server is running, and that you can connect to it from a local client. Now you KNOW that the server is working and properly binding to it's listening port.

Local Machine Firewall: Connect to the server from a different machine on the same LAN. If it fails, fix your server's firewall rules. When you can connect across the LAN, you know that your server is working AND that your firewall is configured properly.

Router: Connect to the server from a machine outside your LAN. Really outside your LAN, not merely on-the-LAN-but-using-the-external-IP-address (the router treats it differently). If the connection fails, fix your router settings. Router settings are generally not an Ubuntu topic...unless you built your own Ubuntu router.

These steps will lead you to the proper follow-up questions.

Related Question