Your VPS is up, CPU looks fine, RAM looks fine, and yet visitors are getting random timeouts. Some requests load instantly, others hang and die. SSH occasionally freezes for a few seconds. Then you run dmesg and see a wall of this:
nf_conntrack: nf_conntrack: table full, dropping packet
nf_conntrack: nf_conntrack: table full, dropping packet
That line means the Linux kernel's connection-tracking table has run out of slots, and it's silently throwing away new connections. It's one of the more confusing VPS problems we help customers with, because nothing in top looks wrong. Let's walk through what's actually happening and how to fix it properly.
Symptom: What This Looks Like in Practice
- Intermittent timeouts on the website, especially during traffic peaks or a bot crawl
- New SSH sessions hang at connect, but existing ones keep working
- Outbound calls (API requests, SMTP, DNS lookups) fail randomly
- Load average and CPU are normal, so monitoring doesn't flag anything
dmesgorjournalctl -kshowstable full, dropping packet
Confirm it with these two commands:
sudo dmesg -T | grep -i conntrack | tail -5
cat /proc/sys/net/netfilter/nf_conntrack_count
cat /proc/sys/net/netfilter/nf_conntrack_max
If nf_conntrack_count is sitting at or very near nf_conntrack_max, you've found your problem.
Cause: Why the Table Fills Up
Whenever you have a stateful firewall loaded (UFW, firewalld, CSF, plain iptables with -m state or -m conntrack, or Docker's NAT rules), the kernel keeps an entry for every connection it sees. That's how rules like "allow established, related" work.
Each entry stays in the table until it times out. The problem is the default timeouts are generous and the default table size is often small, especially on VPS plans with 1–2 GB RAM where the kernel sizes nf_conntrack_max based on memory. Typical culprits:
| Cause | Why it fills the table |
|---|---|
| Traffic spike or aggressive crawler | Thousands of short connections, each held for minutes after closing |
| SYN flood or small DDoS | Half-open connections pile up faster than they expire |
Long established timeout | Default is 432000 seconds (5 days) for idle TCP connections |
| Docker / NAT heavy workloads | Every container connection is tracked, often twice |
| DNS resolver or UDP-heavy service | Every UDP query creates an entry |
| Outbound connection leaks | An app opening connections to an API without reusing them |
Fix: Step by Step
1. See what's actually in the table
Before you just raise limits, find out who's eating the slots. Install the conntrack tool:
# Ubuntu / Debian
sudo apt install conntrack
# AlmaLinux / Rocky
sudo dnf install conntrack-tools
Then break the table down by state and by source IP:
# Count by TCP state
sudo conntrack -L -p tcp 2>/dev/null | awk '{print $4}' | sort | uniq -c | sort -rn
# Top 10 source IPs
sudo conntrack -L 2>/dev/null | grep -oP 'src=\K[0-9.]+' | sort | uniq -c | sort -rn | head
What you're looking for:
- Lots of
TIME_WAIT— normal busy web traffic, fix with timeout tuning - Lots of
SYN_RECV— likely a SYN flood, look at rate limiting and SYN cookies - Lots of
ESTABLISHEDfrom one IP — a scraper or abusive client, block it - Your own server IP as source to one destination — an app leaking outbound connections
2. Get breathing room right now
If the site is actively dropping traffic, raise the limit immediately. This takes effect instantly and doesn't need a reboot:
sudo sysctl -w net.netfilter.nf_conntrack_max=262144
Each entry uses roughly 300 bytes of kernel memory, so 262144 entries is around 75–80 MB. That's fine on a 2 GB VPS. On a 1 GB plan, 131072 is a safer number.
3. Shorten the timeouts
This is the change that usually fixes it for good. A five-day timeout for idle established connections makes no sense for a web server:
sudo sysctl -w net.netfilter.nf_conntrack_tcp_timeout_established=3600
sudo sysctl -w net.netfilter.nf_conntrack_tcp_timeout_time_wait=30
sudo sysctl -w net.netfilter.nf_conntrack_tcp_timeout_close_wait=30
sudo sysctl -w net.netfilter.nf_conntrack_tcp_timeout_fin_wait=30
sudo sysctl -w net.netfilter.nf_conntrack_udp_timeout=30
sudo sysctl -w net.netfilter.nf_conntrack_udp_timeout_stream=60
Watch nf_conntrack_count for a few minutes afterwards. It should drop noticeably as old entries expire faster.
4. Make it permanent
Settings from sysctl -w vanish on reboot. Put them in a drop-in file:
sudo nano /etc/sysctl.d/90-conntrack.conf
net.netfilter.nf_conntrack_max = 262144
net.netfilter.nf_conntrack_tcp_timeout_established = 3600
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 30
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 30
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 30
net.netfilter.nf_conntrack_udp_timeout = 30
net.netfilter.nf_conntrack_udp_timeout_stream = 60
Apply with sudo sysctl --system.
One gotcha: on some distros the nf_conntrack module loads after sysctl runs at boot, so your settings get ignored. Force the module to load early:
echo nf_conntrack | sudo tee /etc/modules-load.d/conntrack.conf
5. Raise the hash table size too
If you raise nf_conntrack_max a lot, bump the hash buckets so lookups stay fast. A good rule is max divided by 4:
echo 65536 | sudo tee /sys/module/nf_conntrack/parameters/hashsize
echo "options nf_conntrack hashsize=65536" | sudo tee /etc/modprobe.d/conntrack.conf
6. Deal with the source, not just the symptom
If step 1 showed one or two IPs holding thousands of entries, block them. With UFW:
sudo ufw insert 1 deny from 203.0.113.45
If you saw a flood of SYN_RECV, make sure SYN cookies are on:
sudo sysctl -w net.ipv4.tcp_syncookies=1
And if it's your own app opening thousands of outbound connections, fix the code to reuse connections (HTTP keep-alive, a persistent DB pool) rather than growing the table forever.
7. Optional: skip tracking for traffic that doesn't need it
On a busy, dedicated web server you can tell the kernel not to track inbound HTTP/HTTPS at all using the raw table. This is advanced — only do it if you understand your firewall rules, because "established/related" matching won't apply to that traffic anymore:
sudo iptables -t raw -A PREROUTING -p tcp --dport 80 -j NOTRACK
sudo iptables -t raw -A PREROUTING -p tcp --dport 443 -j NOTRACK
sudo iptables -t raw -A OUTPUT -p tcp --sport 80 -j NOTRACK
sudo iptables -t raw -A OUTPUT -p tcp --sport 443 -j NOTRACK
You'll also need explicit ACCEPT rules for ports 80/443 in the filter table. For most customers, steps 2–6 are enough and this isn't necessary.
Prevention: Keep It From Coming Back
- Monitor the ratio. Alert when
nf_conntrack_count / nf_conntrack_maxpasses 75%. Netdata tracks this out of the box. - Put Cloudflare or rate limiting in front. Nginx
limit_connandlimit_reqstop a single client from flooding the table. - Keep timeouts sane. Leave the drop-in file in place across upgrades and rebuilds.
- Check after installing Docker. Container NAT adds a lot of entries; re-check the count under real load.
- Size for growth. If you regularly sit above 50% after tuning, it's time for a larger plan with more RAM.
A quick one-liner you can keep handy:
echo "$(cat /proc/sys/net/netfilter/nf_conntrack_count) / $(cat /proc/sys/net/netfilter/nf_conntrack_max)"
Frequently Asked Questions
Will raising nf_conntrack_max slow my server down?
Not noticeably, as long as you also raise the hash size and have the memory for it. Each entry costs around 300 bytes, so even 262144 entries is under 100 MB.
Can I just disable connection tracking completely?
Only if you're running no stateful firewall rules and no NAT (which rules out Docker's default networking). For almost every VPS, tuning is the safer route than unloading the module.
The file /proc/sys/net/netfilter/nf_conntrack_count doesn't exist. Why?
The conntrack module isn't loaded, which means no stateful firewall is active. In that case the dropped-packet error isn't your problem and you should look elsewhere, such as the application or network limits.
Does this affect cPanel servers with CSF?
Yes. CSF uses iptables with connection tracking, so busy cpanel" class="auto-link">wordpress-missing-a-temporary-folder-upload-error" class="auto-link">cPanel VPS servers can hit this too. The same sysctl tuning applies, and CSF's own CT_LIMIT setting can help block IPs that open too many connections.
How do I know the fix worked?
Run dmesg -T | grep conntrack after a busy period. If no new "table full" lines appear and the count stays well below the max, you're done.
