betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

13 March 2009

apache and reverse DNS hostname lookups

No, no, no, it ain't me babe!

Doing reverse DNS hostname lookups on every request in apache (to have those domain names in the log file) is a bad idea as it will slow your server down, everybody seems to agree on that. Yesterday I noticed one of our servers doing just that, despite me not having remembered turning that feature on. Took me a bit of searching and cursing to find the culprit.

There are a few reasons why Apache (or Apache 2) will start looking up hostnames:

... and now please don't ask me why Apple (or is it Apache 2 at fault?) has the LogFormat with %h in their config on Mac OS X 10.5.

Posted by betabug at 10:42 | Comments (9) | Trackbacks (0)
ch athens
Life in Athens (Greece) for a foreigner from the other side of the mountains. And with an interest in digital life and the feeling of change in a big city. Multilingual English - German - Greek.
Main blog page
Recent Entries
Best of
Some of the most sought after posts, judging from access logs and search engine queries.

Apple & Macintosh:
Security & Privacy:
Misc technical:
Athens for tourists and visitors:
Life in general:
<< Café Abyssinia | Main | Shell fun: limit bandwidth on scp >>
Re: apache and reverse DNS hostname lookups

Not always a bad idea: on development machines, it is useful to be able to see which of my testers is doing which requests.

Posted by: Matthew Schinckel at February 15,2010 04:29
Re: apache and reverse DNS hostname lookups

Matthew, such an obscure and rare use as yours case is hardly a good reason to ship apache with a default setting that slows things down this much. Which doesn't mean that your use case is not valid for you, it's just nowhere near what everybody needs.

Posted by: betabug at February 16,2010 11:10
Re: apache and reverse DNS hostname lookups

Thanks dude, helpful post. In my case, having the entry 'localhost' in the 'allow from' clause caused reverse-dns lookups for localhost (that were not successfully resolving) for each request. Since I don't care about localhost, and seems to work OK for local access, I removed that and now I get quick access.

Posted by: mbs at July 25,2011 23:18
Re: apache and reverse DNS hostname lookups

Tried all of those (several times) in the past few weeks, and can't find the cause of a 5-second delay on my machine. For the record, I also tried changing the ServerName directive from localhost:80 to to avoid a lookup, no use. I also added my machine's hostname to my local hosts file, also no use. It seems a lot of people have the same problem, but I can't find the solution...

Posted by: Rasmus Schultz at April 09,2013 16:46
Re: apache and reverse DNS hostname lookups

I am very very very grateful to you!!!!!!!! You heal my headache!!! The "Deny from none" problem drived me crazy!!

Posted by: Junyo at June 06,2013 16:16
Re: apache and reverse DNS hostname lookups

Junyo, you're very welcome! Glad to be of help :-)

Posted by: betabug at June 06,2013 16:34
Re: apache and reverse DNS hostname lookups

the %h to %a changed A LOT my server load.

Posted by: asdf at October 27,2013 01:19
Re: apache and reverse DNS hostname lookups

I would like to add another way you can make apache perform a hostname lookup without you wanting it to do so.

Allow from X.X.X.X #my IP address at home

"#my IP address at home" is considered hostname and apache will perform hostname lookups when accessing the resource (vhost, folder, etc.) where this directive is located.

Posted by: Borislav at November 14,2016 12:50
Re: apache and reverse DNS hostname lookups

Thank you Borislav! So apache interprets "#my IP address at home" at the end of the line as a second address, not as a comment. Very good find!

Posted by: betabug at November 14,2016 15:28
You can trackback to:
There are no trackbacks.