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

Categories: Code

Yu

Ideals are like the stars: we never reach them, but like the mariners of the sea, we chart our course by them.

Leave a Reply

Your email address will not be published. Required fields are marked *