admiral_grinder has asked for the wisdom of the Perl Monks concerning the following question:

I have stumbled upon a interesting problem in our application. When testing our app in a Linux VM that is unable to get a IPv4 address, LWP fails to connect to localhost. This app has the webserver running and Firefox is able to connect to it fine.

The VM: Stock CentOS 6.4 Desktop in Virtual Box on Corporate Win 7 with the following network adapters:

When I bring up a network that has a IPv4 connection, it magically starts working. I take it down and LWP stops working. However, Firefox happily works anyways. Then when I take down all eth interfaces, it works again.

Here is the boiled down test script:

#!perl -w use strict; use LWP; my $browser = LWP::UserAgent->new(); my $response = $browser->get("http://localhost:8080/index.html"); if($response->is_success()) { print "Success\n"; } else { print "Failure\n"; } print "Response: ".$response->as_string();
We have had a few people look into this and it has us stumped. All the system tools for networking still work for us.

Replies are listed 'Best First'.
Re: LWP connecting to LWP issue when no eth has ipv4 address
by choroba (Cardinal) on Jul 08, 2015 at 21:15 UTC
    I've experienced similar problems. I've had to change the localhost entry in /etc/hosts, namely remove localhost from the following line:
    ::1 localhost ipv6-localhost ipv6-loopback
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Thanks, but no luck for me.
A reply falls below the community's threshold of quality. You may see it by logging in.