Can't access port 8100 (ionic serve) on a remote Ubuntu 16.04 server

My test development environment is on a remote Ubuntu server. Ionic and ionic serve runs fine, but I cant access :8100 from a remote browser after running ionic serve (I get a connection refused error in Chrome).

I have iptables set up as following:

-A INPUT -i lo -j ACCEPT
-A INPUT -s ! -i lo -j REJECT --reject-with icmp-port-unreachable
-A INPUT -p icmp -m state --state NEW -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -m state --state NEW -j ACCEPT
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables_INPUT_denied: " --log-level 7
-A INPUT -j REJECT --reject-with icmp-port-unreachable
-A INPUT -p tcp -m tcp --dport 8100 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8100 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
-A FORWARD -m limit --limit 5/min -j LOG --log-prefix "iptables_FORWARD_denied: " --log-level 7
-A FORWARD -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -p tcp -m tcp --sport 8100 -m state --state NEW -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 8100 -m conntrack --ctstate ESTABLISHED -j ACCEPT

After this didn’t work, I tried to add rules with UFW:

Status: active

To                         Action      From
--                         ------      ----
8100                       ALLOW       Anywhere                  
8100/tcp                   ALLOW       Anywhere                          
8100 (v6)                  ALLOW       Anywhere (v6)             
8100/tcp (v6)              ALLOW       Anywhere (v6)

I still get ERR_CONNECTION_REFUSED when I try to access this port from a remote browser. Port 80 and 22 work as normal.

As the for the service itself on port 8100, I have tried have it listen as follows:

dev server running: http://localhost:8100/


dev server running: http://<my server's IP>:8100/

Which also results in ERR_CONNECTION_REFUSED in the remote browser.

1 Like

Did you try to disable the firewall altogether and check if it works. sudo ufw disable
If it did work, it means it’s definitely from the firewall.

1 Like

No that didn’t work as disabling UFW doesn’t seem to affect the rules before it.

The solution was to delete this rule:

-A INPUT -j REJECT --reject-with icmp-port-unreachable

As the additional rules regarding port 8100 were ignored due to the above.

1 Like

No idea how to solve your problem, but a though: Are you sure ionic serve is setup to listen to external requests? Maybe it is only meant to respond to local requests? Then your problem wouldn’t be getting to the “server”, but making it answer your requests.

Solved it as per my comment above.