How to fix NGINX : worker connections are not enough

Sometimes you may get an error “worker connections are not enough” in NGINX if you run a high-traffic website. In this article, we will look at how to fix NGINX: worker connections are not enough error.


How many connections can NGINX handle?

Each NGINX worker can handle a maximum of 512 concurrent connections. In newer versions, NGINX supports up to 1024 concurrent connections, by default. However, most systems can handle more. Nevertheless, this configuration is sufficient for most websites. However, if your website gets too many visitors or if NGINX is not properly configured then you may get a “worker connections not enough” error.


How to fix NGINX : worker connections are not enough

Here are the steps to fix worker connections are not enough error.


1. Open NGINX configuration

Open terminal and run the following command to open NGINX configuration file.

$ sudo vi /etc/nginx/nginx.conf

If you have configured separate virtual hosts for your website (e.g www.example.com), such as /etc/nginx/sites-enabled/example.conf then open its configuration with the following command

$ sudo vi /etc/nginx/sites-enabled/example.conf

Also read : How to Enable HTTP/2 in NGINX


2. Increase Worker Connections

Add the following events block with worker_connections directive to increase the number of worker connections to 2048. You can increase this number if you want.

events {
...
   worker_connections 2048;
...
}

Please note, the number of workers are limited by the amount of memory available on your server. Also, as the number of workers increase, so will the memory consumption of NGINX server.

Also read : How to Disable ETag in NGINX


3. Restart NGINX Server

Finally, run the following command to check syntax of your updated config file.

$ sudo nginx -t

If there are no errors, run the following command to restart NGINX server.

$ sudo service nginx reload #debian/ubuntu
$ systemctl restart nginx #redhat/centos


If you happen to get this error, it is advisable to thoroughly check the server configuration, before increasing the number of worker connections. The default value of worker_connections directive is enough for most websites.

Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it today!

mm

About Ubiq

Ubiq is a powerful dashboard & reporting platform for small & medium businesses. Build dashboards, charts & reports for your business in minutes. Get insights from data quickly. Try it for free today!