'nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size
I'm in the process of setting up a new server. The http-Server of my choice is NGINX. I want to add the domain audi-freunde-einbeck.de as a virtual host. I already have 2 other domains in there and it works fine, but when I try to add the above mentioned domain and start the server it gives me Job failed. See system journal and 'systemctl status' for details.
I thought it was because of the dashes, so I tried just various other domains with and without hyphens, but no luck. Same error. what could be causing this? I also tried rebooting, I am really at a loss here. Any help would be greatly appreciated.
I have played around a bit and found out, that, when I only put one domain in, it works. But when I put another domain in, it stops. Here is the output in status:
[root@netzmelone nginx]# systemctl status nginx
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)
Active: failed (Result: exit-code) since Sun, 16 Dec 2012 11:38:08 +0000; 7s ago
Process: 14239 ExecStop=/usr/sbin/nginx -g pid /run/nginx.pid; -s quit (code=exited, status=1/FAILURE)
Process: 14232 ExecStart=/usr/sbin/nginx -g pid /run/nginx.pid; daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 14242 ExecStartPre=/usr/sbin/nginx -t -q -g pid /run/nginx.pid; daemon on; master_process on; (code=exited, status=1/FAILURE)
Main PID: 14234 (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/nginx.service
Dec 16 11:38:08 netzmelone nginx[14242]: nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
Dec 16 11:38:08 netzmelone nginx[14242]: nginx: configuration file /etc/nginx/nginx.conf test failed
Solution 1:[1]
- open
/etc/nginx/nginx.confwith write privileges - uncomment or add
server_names_hash_bucket_size 64; - restart nginx
sudo service nginx restart
If the error still persists:
- increase
server_names_hash_bucket_sizein steps 128, 256, 512, and so on (increasing by a power of 2 each time). eg.server_names_hash_bucket_size 128; - restart the nginx each time until error is gone (error will always be the same no matter what value you already set)
Solution 2:[2]
This is how I solved:
cd /etc/nginx/
sudo nano nginx.conf
- --uncomment or add server_names_hash_bucket_size 64 --
- --increase server_names_hash_bucket_size "164" --
cd /etc/nginx/sites-available/
sudo nginx -t
- if all it's ok
sudo service nginx restart
Solution 3:[3]
This sounds perhaps a bit random, but it might help an nginx newb like myself.
I got this error when I left off a ; on the server_name line.
had:
server_name www.mydomain.com
access_log /var/log/nginx/www.mydomain.com;
fix:
server_name www.mydomain.com;
access_log /var/log/nginx/www.mydomain.com;
All directives in nginx config files must end with a ;
I often highlight ;s in my file before saving/uploading as a final check after editing.
(To highlight, I use Find All: ;)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SherylHohman |
| Solution 2 | Flavio Oliveira |
| Solution 3 |
