ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Nginx: could not build optimal server_names_hash

    Scheduled Pinned Locked Moved IT Discussion
    nginxlinuxubuntudebianweb server
    2 Posts 2 Posters 36 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by

      Got this error when adding new websites to an Nginx host:

      [warn] : could not build optimal server_names_hash, you should increase either 
      server_names_hash_max_size: 512 or server_names_hash_bucket_size: 64; 
      ignoring server_names_hash_bucket_size
      

      Basically, that warning means nginx has too many / too-long server_name entries now, and the internal hash table it uses to match hostnames is too small. The default config is to keep the hash table quite small.

      You don’t need to change any of your site configs — you need to adjust global nginx hash settings.

      On Ubuntu, the config file is /etc/nginx/nginx.conf

      You should increase one or both of these directives:
      • server_names_hash_max_size
      • server_names_hash_bucket_size

      They go in the http {} block, not inside a server {} block.

      The following example settings will double the default values and likely allow you to grow for a while. Increase as needed...

      http {
          server_names_hash_max_size 1024;
          server_names_hash_bucket_size 128;
      
          ...
      }
      
      1 Reply Last reply Reply Quote 1
      • IThomeboy80I
        IThomeboy80
        last edited by

        Thank you for tip my friend.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post