Hello, friends. Nginx is very popular as a web server, but as always, it is not perfect and can give us some errors. Today, in this post, you will learn how to fix worker connections are not enough error on Nginx. So, you can avoid a headache while managing a server. Let’s go for it.
What is this error about?
When Nginx is handling a website that has many requests, it is common that at some point it gets crashed. This happens because it reaches a limit of requests received.
There are some possible solutions, but the best one is to make Nginx process more of them. That is to say that we have to make it handle more requests than the default number which is 1024
for recent versions.
The number of requests that we will be able to define is limited by the number of resources that our computer has, especially in memory.
So let’s fix this bug.
Fix worker connections are not enough error on Nginx
To fix this error, we need to edit the Nginx configuration file. But if you have several sites created, then you have to open the configuration file of each site where the change will be required.
The Nginx configuration file is /etc/nginx/nginx.conf
and for a custom site, it is /etc/nginx/sites-enabled/your-site.conf
.
Any of these files can be opened with a text editor such as vi
, nano
or vim
with root permissions.
Once you open them, you have to add a section called events
and a worker_connections
directive specifying a number that will set more and more requests accepted.
For example,
events {
worker_connections 2048;
}
Remember that the value of the directive can be whatever you want but will be limited by the memory available on your computer. It should also be noted that this will increase the consumption of Nginx.
Save the changes and close the text editor
Check the Nginx configuration syntax with the command line
sudo nginx -t
If there are no errors, just restart Nginx.
sudo systemctl restart nginx
And you are done.
Conclusion
nginx is a very efficient web server that is not free of problems, and some of these can be solved by changing certain parameters. Today, for example, we have seen how to fix an error that can be annoying for the visitors of our site.
Help us and share this post.