Nginx emerg error: could not build the server_names_hash

Written by - 0 comments

Published on - Listed in Linux Internet Unix Nginx


I saw a weird error today where nginx wouldn't start after setting up the vhost configuration:

nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 64

The reason for this was a very long server_name in the vhost config:

 server_name confluence.myfirsttestpage123.examplewebsite.com ;

The defined server_name was so long, that the hash, generated by the sever_name string, was longer than 64. The current setup had a fixed limit of a hash bucket size of 64:

grep server_names_hash_bucket_size /etc/nginx/nginx.conf
  server_names_hash_bucket_size 64;

By increasing the value to 128, the config was correctly loaded and nginx started up.

grep server_names_hash_bucket_size /etc/nginx/nginx.conf
  server_names_hash_bucket_size 128;

nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Another solution would be to use a shorter server_name, of course.
That would make more sense, agreed. But leave it to the customer to come up with such great server names...


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.