When nftables silently drops your local web server: a step‑by‑step debug

If a browser on the same machine can’t reach http://localhost:8080 but curl from another host works, the culprit is often nftables. Unlike iptables, nftables doesn’t log dropped packets by default, so you may not see any trace in /var/log/syslog. Below is a concise, hands‑on checklist that will help you locate the invisible rule that’s blocking local traffic.

1. Verify the service is listening

sudo ss -tulpn | grep 8080

You should see something like:

LISTEN 0 128 0.0.0.0:8080 0.0.0.0:* users:(("myapp",pid=1234,fd=3))

If the socket is bound only to 127.0.0.1 and you’re trying to reach it via the LAN IP, the service itself is the blocker. Adjust the bind address or use --listen-address 0.0.0.0 if supported.

2. Inspect the default nftables policy

sudo nft list chain inet filter input

The default policy is usually accept. If it’s drop, every packet that doesn’t match a rule will vanish silently. A quick fix for local testing is:

sudo nft add rule inet filter input accept

Remember to make the change persistent with sudo nft list ruleset > /etc/nftables.conf.

3. Check for a “local” drop rule

Search for rules that explicitly match lo or 127.0.0.1:

sudo nft list table inet filter | grep -i lo

A common pattern is:

add rule inet filter input iifname "lo" drop

If you find such a rule, delete it:

sudo nft delete rule inet filter input handle 42   # replace 42 with the rule number

4. Enable packet logging temporarily

To confirm that packets are indeed being dropped, add a logging rule before the drop rule:

sudo nft add rule inet filter input ip daddr 127.0.0.1 log prefix "nft-drop: " level notice

Now try accessing the server again. Check /var/log/syslog (or journalctl -u nftables if you run nftables as a systemd service). You should see entries like:

nft-drop: IN=lo OUT= MAC=... SRC=127.0.0.1 DST=127.0.0.1 LEN=...

If you see the log but no connection, the drop rule is active. Remove the log rule after you’re done:

sudo nft delete rule inet filter input handle 43   # adjust handle

5. Look for masquerade or NAT rules that affect local traffic

Sometimes a masquerade rule in the nat table can rewrite the source address of local packets, causing them to be routed back out of the loopback interface and then dropped. List the nat table:

sudo nft list table nat

If you see a rule like:

add rule nat prerouting ip saddr 192.168.1.0/24 masquerade

and your local traffic is being NATed, consider adding an exception:

add rule nat prerouting ip saddr 127.0.0.1 accept

6. Test with a minimal rule set

If the problem persists, dump the current ruleset and start fresh:

sudo nft flush ruleset
sudo nft add table inet filter
sudo nft add chain inet filter input { type filter hook input priority 0 \; policy accept \; }
sudo nft add rule inet filter input iifname "lo" accept
sudo nft add rule inet filter input ip daddr 127.0.0.1 accept

Now start your web server and try again. If it works, rebuild your full ruleset incrementally, testing after each addition.

7. Persist changes across reboots

nftables can be configured to load a ruleset at boot via /etc/nftables.conf. Ensure the file contains:

#!/usr/sbin/nft -f
table inet filter {
    chain input {
        type filter hook input priority 0; policy accept;
        iifname "lo" accept
        ip daddr 127.0.0.1 accept
        # … your other rules …
    }
}

Enable the service:

sudo systemctl enable nftables
sudo systemctl start nftables

8. Quick sanity check: disable nftables

As a last resort, temporarily disable nftables to confirm it’s the source:

sudo systemctl stop nftables

If the web server becomes reachable, you’ve confirmed nftables is the culprit. Re‑enable it and follow the steps above to isolate the offending rule.


Practical take‑away: nftables is powerful but silent. Adding a short logging rule or flushing the ruleset can quickly reveal hidden drops. Keep your default policy accept during development, and only tighten rules once you’re sure they’re needed.

See also