# Could not build the referers\_hash

**URL:** <https://www.ruby-forum.com/t/could-not-build-the-referers-hash/218389>\
**Category:** NGINX\
**Created:** [March 30, 2012, 2:12am UTC](https://www.ruby-forum.com/t/could-not-build-the-referers-hash/218389 "2012-03-30T02:12:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 30, 2012, 2:12am UTC](https://www.ruby-forum.com/t/could-not-build-the-referers-hash/218389/1 "2012-03-30T02:12:18Z")

</div>

Hello,

I am trying to reload nginx and keep getting this error:

nginx: [emerg] could not build the referers\_hash, you should increase  
referers\_hash\_bucket\_size: 64  
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

Nginx Version: 1.0.8

nginx.conf - [gist:a113dd815b591fa841c3 · GitHub](https://gist.github.com/a113dd815b591fa841c3)

Thanks in advance.

Regards,

Justin D. [http://www.twitter.com/jdorfman](http://www.twitter.com/jdorfman)

---

<div class="post-metadata">

**Author:** ![jmadtech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7cd45c/32.png) [@jmadtech](https://www.ruby-forum.com/u/jmadtech)\
**Post date:** [March 30, 2012, 3:42am UTC](https://www.ruby-forum.com/t/could-not-build-the-referers-hash/218389/2 "2012-03-30T03:42:27Z")

</div>

On Thu, 2012-03-29 at 17:11 -0700, Justin D. wrote:

> nginx: [emerg] could not build the referers\_hash, you should increase  
> referers\_hash\_bucket\_size: 64

I hate to ask the obvious, but did you try increasing  
referers\_hash\_bucket\_size?

server {  
referers\_hash\_bucket\_size 128;  
}

This variable seems undocumented (aside from a note it appeared in  
1.0.5), but the error message appears helpful enough.

Regards,  
Cliff

---

<div class="post-metadata">

**Author:** ![jmadtech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7cd45c/32.png) [@jmadtech](https://www.ruby-forum.com/u/jmadtech)\
**Post date:** [March 30, 2012, 4:04am UTC](https://www.ruby-forum.com/t/could-not-build-the-referers-hash/218389/3 "2012-03-30T04:04:41Z")

</div>

Hey Cliff,

I did, same issue. The way we ended up “fixing” it was deleting all of  
the  
vhosts and syncing them from another PoP.

Thanks

Regards,

Justin D. [http://www.twitter.com/jdorfman](http://www.twitter.com/jdorfman)

---

<div class="post-metadata">

**Author:** ![jmadtech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7cd45c/32.png) [@jmadtech](https://www.ruby-forum.com/u/jmadtech)\
**Post date:** [March 30, 2012, 5:17pm UTC](https://www.ruby-forum.com/t/could-not-build-the-referers-hash/218389/4 "2012-03-30T17:17:49Z")

</div>

On Thu, 2012-03-29 at 19:04 -0700, Justin D. wrote:

> Hey Cliff,
> 
> I did, same issue. The way we ended up “fixing” it was deleting all  
> of the vhosts and syncing them from another PoP.

How large did you make the value? With a large number of vhosts the  
value might need to be significantly higher. Also, I’m not sure of the  
context for this value, it might need to be at the http level.

There’s also a related value, referers\_hash\_bucket\_size that might need  
to be increased.

The only information I found was from this thread (translated from  
Russian via google):

2011/7/19 Igor S. [igor@xxxxxxxxx](mailto:igor@xxxxxxxxx):

> Changes in nginx 1.0.5 19.07.2011
> 
> \*) Feature: the referer\_hash\_max\_size and  
> Referer\_hash\_bucket\_size.  
> Thank you Witold Filipczyk.

With these guidelines, there are some problems:

- In the error messages as they are called, and referers\_hash\_max\_size  
referers\_hash\_bucket\_size
- The default value for referer\_hash\_max\_size in the error message  
described as a 128 (actually - 2048)
- It is not clear how to find exactly where the problem  
that is, such as the diagnosis is  
nginx: [emerg] could not build the referers\_hash, you should increase  
referers\_hash\_bucket\_size: 64  
But that’s not enough, as the context for referer\_hash\_max\_size server  
and location

Regards,  
Cliff

---

<div class="post-metadata">

**Author:** ![jmadtech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7cd45c/32.png) [@jmadtech](https://www.ruby-forum.com/u/jmadtech)\
**Post date:** [March 30, 2012, 11:50pm UTC](https://www.ruby-forum.com/t/could-not-build-the-referers-hash/218389/5 "2012-03-30T23:50:49Z")

</div>

On Fri, 2012-03-30 at 09:08 -0700, Justin D. wrote:

> Hey Cliff,
> 
> Here are the current values:
> 
> server\_names\_hash\_max\_size 65536;  
> server\_names\_hash\_bucket\_size 256;

These are not the hashes you are looking for =) Your error message  
specified “you should increase referers\_hash\_bucket\_size”, indicating  
that it is currently 64.

Regards,  
Cliff

---

<div class="post-metadata">

**Author:** ![jmadtech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7cd45c/32.png) [@jmadtech](https://www.ruby-forum.com/u/jmadtech)\
**Post date:** [April 9, 2012, 9:50pm UTC](https://www.ruby-forum.com/t/could-not-build-the-referers-hash/218389/6 "2012-04-09T21:50:27Z")

</div>

Our senior engineer figured how to fix it.

What he did was edited this file:  
src/http/modules/ngx\_http\_referer\_module.c

and changed this line:  
prev-\>referer\_hash\_bucket\_size, 64);

to:  
prev-\>referer\_hash\_bucket\_size, 128);

Then recompiled nginx.

Hope that helps someone in the future.

Regards,

Justin D. [http://www.twitter.com/jdorfman](http://www.twitter.com/jdorfman)

---

<div class="post-metadata">

**Author:** ![jmadtech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7cd45c/32.png) [@jmadtech](https://www.ruby-forum.com/u/jmadtech)\
**Post date:** [April 10, 2012, 1:16pm UTC](https://www.ruby-forum.com/t/could-not-build-the-referers-hash/218389/7 "2012-04-10T13:16:22Z")

</div>

Hello!

On Mon, Apr 09, 2012 at 12:49:43PM -0700, Justin D. wrote:

> Then recompiled nginx.
> 
> Hope that helps someone in the future.

There is configuration directive to adjust this,  
referer\_hash\_bucket\_size. You don’t need to edit the code.

Maxim D.

> > On Fri, 2012-03-30 at 09:08 -0700, Justin D. wrote:  
> > specified “you should increase referers\_hash\_bucket\_size”, indicating

---

<div class="post-metadata">

**Author:** ![jmadtech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7cd45c/32.png) [@jmadtech](https://www.ruby-forum.com/u/jmadtech)\
**Post date:** [April 10, 2012, 3:53pm UTC](https://www.ruby-forum.com/t/could-not-build-the-referers-hash/218389/8 "2012-04-10T15:53:52Z")

</div>

> There is configuration directive to adjust this,  
> referer\_hash\_bucket\_size. You don’t need to edit the code.
> 
> Maxim D.

I got caught by this bug too,

Seems a bit strange why the defaults (if not set) complains that its  
not enough.. I can see why people edit the code directly.

If 64 isn’t clearly enough when referer\_hash\_bucket\_size isn’t set,  
why not just up the default to 128 to avoid this unnecessary complaint  
by nginx.

---

<div class="post-metadata">

**Author:** ![jmadtech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7cd45c/32.png) [@jmadtech](https://www.ruby-forum.com/u/jmadtech)\
**Post date:** [March 30, 2012, 6:09pm UTC](https://www.ruby-forum.com/t/could-not-build-the-referers-hash/218389/9 "2012-03-30T18:09:53Z")

</div>

Hey Cliff,

Here are the current values:

server\_names\_hash\_max\_size 65536;  
server\_names\_hash\_bucket\_size 256;

The number of vhosts we have on that cluster is 23,252 (not all active,  
need to clean that up.)

Are those values sufficient for the amount of vhosts?

FYI We have 32gb of ram if that makes any difference.

Regards,

Justin D. [http://www.twitter.com/jdorfman](http://www.twitter.com/jdorfman)

---

<div class="post-metadata">

**Author:** ![jmadtech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7cd45c/32.png) [@jmadtech](https://www.ruby-forum.com/u/jmadtech)\
**Post date:** [April 10, 2012, 4:44pm UTC](https://www.ruby-forum.com/t/could-not-build-the-referers-hash/218389/10 "2012-04-10T16:44:52Z")

</div>

Hello!

On Wed, Apr 11, 2012 at 01:53:08AM +1200, Ryan B. wrote:

> If 64 isn’t clearly enough when referer\_hash\_bucket\_size isn’t set,  
> why not just up the default to 128 to avoid this unnecessary complaint  
> by nginx.

The default is enough in most cases. There are some specific  
situations (long values in hash, multiple colliding values) which  
trigger the message, and the message itself explains what to do  
(and we have the page at [Setting up hashes](http://nginx.org/en/docs/hash.html) which  
explains details).

We might want to better (read: automatically) handle some  
situation like non-colliding long values, where the only sensible  
solution is to increase …\_hash\_bucket\_size, but this has nothing  
to do with defaults change. With any default one will be able to  
write a configuration which triggers the “could not build hash”  
message.

Maxim D.
