0 votes
by Talented


When I run nginx -t I receive the following warning:

nginx: [warn] could not build optimal fastcgi_params_hash, you should increase either fastcgi_params_hash_max_size: 512 or fastcgi_params_hash_bucket_size: 64; ignoring fastcgi_params_hash_bucket_size

I've seen the nginx documentation and from what I can understand, this seems to be related to the number of sites (domains) that exist on the server (more than 30). I remember that I had a similar issue on my old VPS (Centos) which I solved by increasing the server_names_hash_max_size on /etc/nginx/nginx.conf. On my current setup, though, server_names_hash_max_size is already set to 2048, which seems high enough. I tried doubling  it nevertheless, and I also tried setting server_names_hash_bucket_size and then restarting nginx, but both times the warning remained.

I've also seen a similar question on which it is suggested that I could try clearing the FastCGI cache or increase the "fastcgi_params_hash_max_size" in nginx.conf file. I tried the first option (webinoly -clear-cache=fastcgi and even webinoly -clear-cache=all) but the warning persisted.

As for the second suggestion, I am not sure how I could set the fastcgi_params_hash_max_size. When I add fastcgi_params_hash_max_size 2048; on my /etc/nginx/nginx.conf, nginx -t throws an error:

nginx: [emerg] unknown directive "fastcgi_params_hash_max_size" in /etc/nginx/nginx.conf

What puzzles me is the wording of the initial warning, which mentions "fastcgi_params_" instead of "server_names_" which, based on what I saw on most Google results, is the typical warning that appears on similar occasions.

I know that what nginx -t throws is just a warning and that the server still starts, but I am curious to figure it out. After a lot of searching I couldn't find anything online so I thought I 'd ask here too, in case it has something to to with some specific setting set by Webinoly.


1 Answer

0 votes
by Expert

Hi George,

To be honest, I have never figured it out what is wrong with this issue. Nginx documentation about this topic is very vague and unclear, also this warning seems to appear in a very random way, I have seen it in servers with 1 or 2 sites hosted. That's the reason I increased the server names variable to 2048 to prevent this issue, but it seems like now it's related to something in the FastCGI cache area.

I have tried a lot of things with no success, so definitely I have no idea about what is happening, would be great if someone can help us to understand this issue and how to prevent it.

by Talented
It seems that fastcgi_params_hash_max_size and server_names_hash_max_size are unrelated. In order to make sure that server_names_hash_max_size actually does something and is not overlooked I tried lowering its value to 8. At that, nginx -t threw a warning that I should increase it. After restoring it, I got back the initial warning about fastcgi_params_hash_max_size.
by Expert

Totally agree!

The problem here is that fastcgi_params_hash_max_size is marked as an unknown directive.

by Talented

FYI, I posted the question on Stackoverflow to get more attention. There was an answer already but I don't know how much it helps.

by Expert

Thanks a lot, George!

I will keep an eye on that link, definitely, I will play and do some testing with the fastcgi_params as is suggested in the first answer, sounds logical to me.

by Talented

As a sidenote on the subject, I stumbled upon this page on EasyEngine, about how to optimize server_names_hash_max_size and server_names_hash_bucket_size. So, I was wondering if instead of hardcoding those values on nginx.conf, it would be better if they were automatically adjusted every time a new site was added or removed. Of course, I don't know how easy or difficult it would be to implement or how much impact it would actually make on the overall server optimization.

by Expert
Yes, I will take it for the next year roadmap.

Would be great if we found something similar for fastcgi hash.

Thanks, Georgios!
Welcome to the Community site for Webinoly.

Our Optimized LEMP Web Server is a powerful set of commands for doing just about anything you could wish.

With Webinoly you can set up your NGINX web server in just one step.

* * * * * * *

If you have a question about Webinoly, please ask in English or Spanish.

To report a bug, please ask a question here with the bug tag.


Webinoly Support Paypal Donations Webinoly Support Bitcoin Donations GitHub Sponsors

Your regular donations is what keep this project moving forward. If you like Webinoly, buy me a coffee or a beer to show support.

Affiliate Links

It is very important that any visitor to the site read the disclaimer, terms of use and privacy and legal statement before start browsing.