Nginx: worker_connections are not enough, reusing connections

We meet an error log on nginx: worker_connections are not enough, reusing connections. To resolve this issue, here is my working solution according to the references:

Update Configs

Nginx Config

user nginx;
worker_processes 8;
worker_rlimit_nofile 65535;

events {
worker_connections 65535;
multi_accept on;
use epoll;
}

Service Config

[Service]
LimitNOFILE=65535

Restart Service

Check current max open files limit first:

# cat /proc/$(cat /var/run/nginx.pid)/limits|grep open.files
Max open files 1024 1024 files

Then, we reload the systemd and restart the service

systemctl daemon-reload
systemctl restart nginx.service

Check again:

# cat /proc/$(cat /var/run/nginx.pid)/limits|grep open.files
Max open files 65535 65535 files

It should works, and no further error should bump up.

Useless Config

If regular users encounter this issue, we might consider updating the limits conf as follows:

nginx soft nofile 65535
nginx hard nofile 65535

It neither works nor is necessary.

References

stackoverflow: worker_connections are not enough

serverfault: nginx uLimit ‘worker_connections exceed open file resource limit: 1024’

How to Solve CentOS 7 raise nofile limit for Nginx