This has me scratching my head.

UPDATE: I can explain it! It's Apple braindeadedness. It would appear that something changed with Lion, maybe even as recent as 10.7.2 Host lookups go to DNS first, then to /etc/hosts. And it would appear there's no way around this behaviour. People have gone for various kludges, the favourite being to run dnsmasq locally and have DNS resolution hit localhost - dnsmasq will look at /etc/hosts first.

Maybe the tests for WWW::Mechanize need something to work around this?

I can't explain it, but I have managed to fix it.

Whilst trying to install Test::WWW:Mechanize::Catalyst, WWW::Mechanize was failing its tests. I took a deeper look, and could see the failure happening during t/local/back.t, specifically during the 404 testing section.

A new HTTP daemon is run up on localhost, but the URL was returning my DSL router address! A quick standalone test confirmed this:

mb:~$ ./xx.pl
$VAR1 = 'http://o2wirelessbox.lan:63753/';
mb:~$ grep LocalAddr xx.pl
my $server = HTTP::Daemon->new(LocalAddr => 'localhost') or die;
Huh?! Even if I used 127.0.0.1 it still behaved the same. localhost is in /etc/hosts as 127.0.0.1, I can't see why this would behave in this manner.

Changing the address to a known local IP though, of the wifi interface in this case, fixed it.

I'd really like to be able to understand WHY this is happening, but I haven't a clue. If you have, please do leave a comment.


Comments

comments powered by Disqus