Nginx on Fedora 26: could not build optimal types_hash error message
Asked Answered
Y

3

35

I've installed Fedora and Ngnix, added all the configuration files for my local development, when I started to see this error

nginx: [warn] could not build optimal types_hash, you should increase either types_hash_max_size: 2048 or types_hash_bucket_size: 64; ignoring types_hash_bucket_size
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

I found solutions saying that I should add types_hash_bucket_size to nginx.conf, but I've added it, removed the default one, removed both and added both, it insists on showing this error.

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile                            on;
    tcp_nopush                          on;
    tcp_nodelay                         on;
    keepalive_timeout                   65;

    # I tried leaving both, removing both and one of each. The error persists.
    types_hash_max_size                2048;
    server_names_hash_bucket_size      128;

types_hash_max_size was there by default when I installed nginx, though.

My files from sites-enabled:

server {
  listen 80;
  server_name devapi.hporder.com;

  root /home/gabriel/Sites/hp-order-system/workspace/api;

  client_max_body_size 10M;

  location ~ ^/(images|javascript|js|css|flash|media|static)/  {
    expires 30d;
  }

  location / {
    index  index.php index.html index.htm;
    try_files $uri $uri/ /index.php$is_args$args;
  }

  error_page   500 502 503 504  /50x.html;
  location = /50x.html {
    root   /usr/local/Cellar/nginx/1.10.1/html;
  }

  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    fastcgi_param FF_BOOTSTRAP_ENVIRONMENT dev;
    fastcgi_param FF_BOOTSTRAP_CONFIG api/dev;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    # include /usr/local/etc/nginx/fastcgi.conf;

    fastcgi_buffer_size 1024k;
    fastcgi_buffers 1024 1024k;
    fastcgi_busy_buffers_size 1024k;
  }
}
Yeoman answered 4/9, 2017 at 6:35 Comment(1)
I'm on Fedora 27 and also receive this warning running Nginx out-of-the-box. Could it be that the default configuration on Fedora is just wrong?Brother
I
50

On Fedora 25, I had this problem as well. types_hash_max_size was set to 2048 (nginx documentation indicate it defaults to 1024). I simply increased it to 4096 and nginx was happy (checked with nginx -t).

FWIW, in my configuration there is no setting related to the hash bucket size. It's just the default.

Illusive answered 5/12, 2017 at 21:28 Comment(0)
Y
24

Just open the file nginx.conf and just below keepalive_timeout 65; add types_hash_max_size 4096;

Yovonnda answered 13/4, 2021 at 22:52 Comment(0)
G
0

I got the same error and this fix got me in types_hash_max_size 4096; mine was amazon linux

Gillum answered 23/7, 2024 at 6:56 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.