IPv4 & IPv6 Leasing - Any RIR, Any LocationOrder Now
Hostperl

Ubuntu Server Routing Table and Port Troubleshooting

By Raman Kumar

Share:

Updated on Oct 29, 2026

Ubuntu Server Routing Table and Port Troubleshooting

When a port is open but the service still fails

The quickest way to track down a connectivity problem on an Ubuntu server is to check the route, then the listening port, then the firewall. If one of those pieces is wrong, the service may look fine on the server and still fail from a client. This tutorial shows you how to follow that path on Ubuntu Server and fix the common breakpoints without locking yourself out.

Use this guide if you manage a fresh VPS, a migrated site, or a production server where a service responds on localhost but not from the public internet. The same workflow also helps after network changes, IPv4 or IPv6 updates, and new firewall rules on a Hostperl VPS. If you are comparing where to host a service, a Hostperl VPS gives you a clean place to test routing and firewall changes before you move a live workload.

This tutorial focuses on Ubuntu Server and its native tools: ip, ss, ufw, netplan, and systemd. For context on how network mistakes affect migrations, see Debian 12 network diagnostics for VPS connectivity and technical SEO signals hosting buyers trust in 2026 if your service is a public web app that also depends on clean crawlability and uptime.

What you need before you change anything

  • An Ubuntu Server 24.04 or Ubuntu Server 26.04 VPS.
  • Root SSH access for the first pass.
  • A second terminal on your local computer for testing after changes.
  • A service that should listen on port 8000 for this example.

Keep your original SSH session open until you verify the new route and firewall state. That avoids accidental lockouts.

Log in and confirm the operating system

On your local computer, connect with the documentation IP below. Replace 203.0.113.10 with the real public IP assigned by your provider.

ssh root@203.0.113.10

If your provider gives you a default non-root account, use that same IP with the provided username instead. Stay in the root session for the first checks.

On the VPS as root, confirm the platform and note the active network state.

cat /etc/os-release

You should see Ubuntu release data. If you do not, stop here and use the procedure that matches your server.

Next, inspect the current address, route, and default gateway.

ip addr show
ip route show

Successful output shows at least one interface with an IPv4 address, and usually a default route through your provider gateway. If the default route is missing, the server may not reach the internet even if the interface is up.

Build a non-root admin account safely

Do not edit network rules as root for the rest of the session. Create a sudo user first, then test it in a second terminal.

On the VPS as root, create the deploy user, add it to sudo, and set up SSH access.

adduser deploy

Enter a strong password when prompted. If your workflow uses key-only SSH, you can later lock password login for this account after key access works.

usermod -aG sudo deploy
mkdir -p /home/deploy/.ssh
chmod 700 /home/deploy/.ssh

Now add your public key. Replace the example key string with your own.

printf '%s
' 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExampleKeyForDeployOnly user@example.com' > /home/deploy/.ssh/authorized_keys
chmod 600 /home/deploy/.ssh/authorized_keys
chown -R deploy:deploy /home/deploy/.ssh

Open a second terminal and test the new login.

On your local computer, start a second SSH session.

ssh deploy@203.0.113.10

Once logged in, confirm sudo works.

sudo -v

If that succeeds, you can keep working as deploy. Leave the original root session open until all changes are verified.

Check what is listening and where

A service can bind to localhost only, a private interface only, or the public address. Find out which one applies before you change the firewall.

On the VPS as the non-root sudo user, inspect listening sockets.

ss -tulpn

You want to see the application bound to 0.0.0.0:8000 or your public IPv4 address if it should be reachable from outside. If you only see 127.0.0.1:8000, the service is listening only on loopback and no firewall change will fix it.

Check the service status if it runs under systemd.

systemctl status your-app.service --no-pager

Replace your-app.service with the real unit name. A healthy service should show active (running).

Fix the Ubuntu Server routing table

On Ubuntu, the network stack is usually controlled by netplan. If the default route is wrong or missing, repair the netplan file before touching firewall rules.

On the VPS as root, list the netplan files.

ls -l /etc/netplan/

Open the active file with nano or your editor of choice. This example uses 01-netcfg.yaml; your file name may differ.

nano /etc/netplan/01-netcfg.yaml

Use a safe static example like this if your VPS should use a fixed address. Replace the interface name, address, gateway, and DNS values with the ones from your provider.

network:
  version: 2
  ethernets:
    ens3:
      addresses:
        - 203.0.113.10/24
      routes:
        - to: default
          via: 203.0.113.1
      nameservers:
        addresses:
          - 1.1.1.1
          - 8.8.8.8

Save and exit nano with Ctrl+O, Enter, then Ctrl+X.

Before applying, test the configuration.

netplan try

If the route is wrong, netplan try gives you a rollback timer. That is safer than applying blindly. If it looks correct, apply it.

netplan apply

Confirm the route now exists.

ip route show

You should see a default route through your gateway. If the route disappears after reboot, re-check the YAML spacing; netplan is strict about indentation.

Open the port with UFW without exposing too much

Ubuntu Server commonly uses UFW for firewall management. Add the new application port before you restrict anything else. This keeps the service reachable while you test.

On the VPS as the non-root sudo user, allow SSH first if it is not already present, then allow your app port.

sudo ufw allow OpenSSH
sudo ufw allow 8000/tcp

Check the rules before you enable or reload the firewall.

sudo ufw status numbered

If UFW is inactive and this is a fresh server, enable it only after SSH is allowed.

sudo ufw enable

Confirm the status again.

sudo ufw status verbose

A successful result should show Status: active and an allow rule for port 8000. If you later decide to remove the rule, keep your SSH rule in place until after you confirm alternate access.

Test the service locally and from the outside

A routing fix is only useful if the service responds from both the server and your client. Check both sides.

On the VPS as the non-root sudo user, test the app locally.

curl -I http://127.0.0.1:8000

If the app serves HTTP, you should see a status line such as HTTP/1.1 200 OK. If this fails, the problem is inside the app, not the network.

On your local computer, test the public address.

curl -I http://203.0.113.10:8000

Replace the example IP with your server IP. If this works locally but not remotely, your provider security group, external firewall, or routing policy may still block the port.

Diagnose the three most common failures

These are the problems support teams see most often after a migration or rebuild.

1. The service listens only on localhost

Diagnostic command:

ss -tulpn | grep 8000

Expected clue: only 127.0.0.1:8000 appears.

Next action: change the app or systemd unit so it binds to 0.0.0.0 or the server’s public interface, then restart the service.

2. The route is missing after reboot

Diagnostic command:

ip route show

Expected clue: no default route is listed.

Next action: fix the netplan file and rerun netplan try before applying it.

3. UFW allows the port, but the server still times out

Diagnostic command:

sudo ufw status verbose

Expected clue: UFW shows the port allowed, but the client still cannot connect.

Next action: check your hosting control panel or cloud security group, then verify the provider-level firewall. On some setups, the instance firewall is only one layer.

Lock down SSH only after the new access path works

Do not disable root login until you have tested the deploy account in a second terminal. Once that is confirmed, you can reduce SSH exposure.

On the VPS as root, edit SSH settings carefully.

nano /etc/ssh/sshd_config

Add or confirm these lines near the bottom of the file.

PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes

Save and exit. Then test the SSH configuration before reloading.

sshd -t

If there is no output, the syntax is valid.

Reload SSH safely.

systemctl reload ssh

Open a fresh terminal and confirm you can still log in as deploy. Do not close the original root session until that succeeds.

Confirm persistence after reboot

Restarting once is the easiest way to prove the route, firewall, and service all survive a normal maintenance cycle.

On the VPS as root or as the non-root sudo user, reboot the server.

sudo reboot

Wait for the server to return, then reconnect from your local computer.

ssh deploy@203.0.113.10

After login, recheck the route, firewall, and service.

ip route show
sudo ufw status verbose
systemctl status your-app.service --no-pager

If all three look correct, your change is stable.

Why this workflow works well for Hostperl customers

This sequence matches how real hosting support teams troubleshoot production incidents: first the route, then the socket, then the firewall, then persistence. It is a practical fit for migrations, new VPS builds, and launch prep on a managed VPS hosting plan or a self-managed server.

If you are preparing a public service that depends on reliable transport, DNS, and uptime, it is also worth reviewing DNSSEC for hosting buyers and the 2026 hosting market guide to align networking choices with the rest of your stack.

If you want a server environment where you can test routing, firewall rules, and service exposure with support behind it, Hostperl can help you move faster. A Hostperl VPS is a practical fit for most application and connectivity troubleshooting work, while dedicated workloads can move to dedicated server hosting when you need more control over networking and isolation.

For launch-critical services, keep your changes small, verify each layer, and ask support to review the provider-side network path before you cut over.

FAQ

Why does curl work on the server but not from my laptop?

That usually means the app listens only on localhost or a firewall blocks the public port. Check ss -tulpn first, then ufw status verbose.

Should I use a static route or DHCP on Ubuntu Server?

Use the method your provider documents for that VPS. Most fresh servers use a static address and a provider gateway, which you configure in netplan.

Can UFW fix a bad netplan route?

No. UFW controls packet access, not routing. If the default route is missing, fix netplan first.

What is the safest way to avoid lockout?

Keep the original root SSH session open, create the deploy user, test the new login in a second terminal, then change SSH restrictions only after the new path works.