The Setup
Parrot OS, Nginx installed via apt, default config. No rate limiting. No connection caps. No CDN. Just a web server on localhost.

$ curl http://localhost
Welcome to nginx!

The "attacker" is hey (Go-based load tester) on the same machine:

hey -n 50000 -c 10000 -disable-keepalive http://localhost/

50,000 total requests, 10,000 concurrent connections, no keepalive (every request = new TCP connection). This is a load test, not a DDoS. But the failure mode is identical to what a real flood does to a misconfigured server.

The "vulnerability" is the default file descriptor limit:

$ ulimit -n
1024

Default Nginx on Debian/Parrot ships with:

Setting Value
worker_processes auto (4 workers)
worker_connections 512 (default)
limit_req not set
limit_conn not set
ulimit -n 1024
net.core.somaxconn 4096
net.ipv4.tcp_max_syn_backlog 512

Act 1: The Bare Server Dies Silently
I ran the test. Here's what hey reported:

$ hey -n 50000 -c 10000 -disable-keepalive http://localhost/

Summary:
Total: 5.6736 secs
Slowest: 3.1000 secs
Fastest: 0.0251 secs
Average: 1.0043 secs
Requests/sec: 8812.6858

Status code distribution:
[200] 8784 responses

Error distribution:
[39935] Get "http://localhost/": EOF
[1281] Get "http://localhost/": http: server closed idle connection

80% of my requests never got a response. Not a 503. Not a 502. Not even a TCP RST the client could interpret. Just... EOF. The connection opened, and then nothing came back.

I checked the Nginx error log:

$ tail -f /var/log/nginx/error.log

Empty. Zero entries. Nginx had no idea it was losing connections.

I checked the kernel:

$ netstat -s | grep -i "reset|drop"

880 connection resets received 

10135 resets sent
2201 connections reset due to unexpected data
562 connections reset due to early user close

10,135 resets sent by the kernel. The TCP stack was dropping SYNs and sending RSTs before Nginx ever called accept(). The tcp_max_syn_backlog of 512 overflowed almost instantly under 10,000 concurrent connections.

From the user's perspective: their browser shows "Connection Reset" or just hangs. No error page. No status code. The sysadmin checking Nginx logs finds nothing.

Act 2: I Raised the Limits. It Got Worse.
The obvious "fix" is to raise everything:

Kernel: allow more pending SYNs

sudo sysctl -w net.core.somaxconn=65535
sudo sysctl -w net.ipv4.tcp_max_syn_backlog=65535

Nginx: allow more file descriptors

/etc/systemd/system/nginx.service.d/override.conf

[Service]
LimitNOFILE=65535
LimitNOFILESoft=65535

Nginx: raise listen backlog

listen 80 backlog=65535;

I applied all of it. Verified:

$ systemctl show nginx | grep LimitNOFILE
LimitNOFILE=65535
LimitNOFILESoft=65535

$ sysctl net.core.somaxconn
net.core.somaxconn = 65535

Re-ran the exact same test:

$ hey -n 50000 -c 10000 -disable-keepalive http://localhost/

Summary:
Total: 5.5822 secs
Slowest: 1.4389 secs
Fastest: 0.0146 secs
Average: 0.4700 secs
Requests/sec: 8956.9952

Status code distribution:
[200] 5520 responses

Error distribution:
[42933] Get "http://localhost/": EOF
[1547] Get "http://localhost/": http: server closed idle connection

86% dead. Up from 80%.

I went from 8,784 successful responses to 5,520. The "fix" made things 1.6x worse.

Why Raising Limits Made It Worse
This is the counterintuitive part, and it's the whole point of this article.

When somaxconn is 4096, the kernel's accept queue holds at most 4,096 completed handshakes. Once it's full, the kernel drops new SYNs immediately. The client retries a few times, gives up, and you get an EOF. The failure is fast and bounded.

When somaxconn is 65,535, the accept queue can hold 65,535 completed handshakes. Now the kernel accepts every SYN and queues the connection. But Nginx's workers can only accept() so fast. The queue grows to thousands of pending connections. The kernel's TCP stack starts timing out individual connections in the queue, sending RSTs in bulk. You get more EOFs because the failure is now delayed and cascading instead of fast and clean.

A bigger bucket doesn't help if the drain is the same size. You just let more water in before it overflows, and the overflow is messier.

Act 3: Rate Limiting (Partial Improvement)
The real defense isn't more capacity. It's rejecting the flood early so it never reaches the accept queue:

/etc/nginx/nginx.conf, inside http { }

limit_req_zone $binary_remote_addr zone=flood:10m rate=100r/s;
limit_conn_zone $binary_remote_addr zone=conn:10m;
limit_req_status 429;
limit_conn_status 429;

server { } block

location / {
limit_req zone=flood burst=100 nodelay;
limit_conn conn 100;
return 200 "OK\n";
add_header Content-Type text/plain;
}

Re-ran the same test:

$ hey -n 50000 -c 10000 -disable-keepalive http://localhost/

Summary:
Total: 5.9076 secs
Slowest: 2.5803 secs
Fastest: 0.0011 secs
Average: 0.9384 secs
Requests/sec: 8463.7342

Status code distribution:
[200] 12976 responses

Error distribution:
[36029] Get "http://localhost/": EOF
[994] Get "http://localhost/": http: server closed idle connection
[1] Get "http://localhost/": read tcp 127.0.0.1:56156->127.0.0.1:80:
read: connection reset by peer

Still 72% dead. But two things changed:

12,976 got through (up from 5,520 with raised limits alone). The rate limiter is doing its job. It's letting legitimate traffic through while blocking the flood.
That single connection reset by peer is the first time Nginx is actively acknowledging the attack. It's not silent anymore.
Why It's Not 100% Yet
Rate limiting alone can't save a single VPS from 10,000 concurrent connections. In production, you'd layer:

CDN in front (Cloudflare free tier) to absorb volumetric floods before they reach your server
limit_req + limit_conn to reject excess at the app layer
Kernel tuning for somaxconn + tcp_max_syn_backlog (but NOT to 65535. 4096 is fine)
Monitoring to alert when EOF rate > 5% or netstat -s resets spike
The rate limiter is one layer, not the whole defense.

The Results
Approach 200s EOFs % Dead User Sees Sysadmin Sees
Bare Nginx (default) 8,784 39,935 80% "Connection Reset" / hang Nothing in logs
Raised limits (somaxconn=65535) 5,520 42,933 86% "Connection Reset" / hang Nothing in logs
Rate limiting + raised limits 12,976 36,029 72% "Connection Reset" / hang 1 RST in logs

Three Takeaways

  1. The kernel is your first line of defense, and it fails silently. tcp_max_syn_backlog overflow doesn't log to Nginx. When you see unexplained connection failures, check netstat -s | grep "resets sent" before blaming the app.

  2. Raising limits is not a security fix. It's a capacity fix. A bigger accept queue under flood = more queued connections = worse cascading failures. You need to reduce the load, not increase the bucket.

  3. limit_req + limit_conn are your actual first defense. They're two lines of config. They turn a silent death into at least a server that acknowledges the attack. Every production Nginx server should have them. If yours doesn't, add them today.

Reproduce This

Install (Parrot/Debian/Ubuntu)

sudo apt install nginx
go install github.com/rakyll/hey@latest

Start

sudo systemctl start nginx

Kill it

hey -n 50000 -c 10000 -disable-keepalive http://localhost/

Check the damage

netstat -s | grep "resets sent"

The "fix" that makes it worse

sudo sysctl -w net.core.somaxconn=65535

Add LimitNOFILE=65535 to systemd override

sudo systemctl daemon-reload && sudo systemctl restart nginx
hey -n 50000 -c 10000 -disable-keepalive http://localhost/

Worse. 86% dead.

The actual fix

Add limit_req + limit_conn to nginx config

sudo systemctl restart nginx
hey -n 50000 -c 10000 -disable-keepalive http://localhost/

Better. Server acknowledges the flood.