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


Dear Monks,

I had a web grabbing program (using LWP) successfully running on 3 environments previously.

The 3 environments are Test, Pre-Prod, and Prod.

However today the program on Pre-Prod begins to get '500' error when making its first GET to fetch the raw web page. (it fetches the web page so that to start the login process)

Then, I changed the request to be 'POST', but no luck...

So, I'm wondering if anything wrong, because the Test env (using proxy) and the Prod env (without proxy) are working good, but just the Pre-Prod...

I paste the code to make the simple requeste and also the detailed '500' response here:



   200      my $res = $ua->request(POST $gLoginURL);
   202      if ( !$res->is_success ) {
   203          $self->{log}->die("ERROR:\t" . Dumper($res));
   204      }


BAD response

2014/09/24 10:34:30 CRITICAL: FATAL: ERROR:     $VAR1 = bless( {
                 '_content' => '500 Can\'t connect to (Bad hostname \'\')
                 '_rc' => 500,
                 '_headers' => bless( {
                                        'client-warning' => 'Internal response',
                                        'client-date' => 'Wed, 24 Sep 2014 14:34:30 GMT',
                                        'content-type' => 'text/plain'
                                      }, 'HTTP::Headers' ),
                 '_msg' => 'Can\'t connect to (Bad hostname \'\')',
                 '_request' => bless( {
                                        '_content' => '',
                                        '_uri' => bless( do{\(my $o = '')}, 'URI::http' ),
                                        '_headers' => bless( {
                                                               'user-agent' => 'libwww-perl/5.804',
                                                               'content-type' => 'application/x-www-form-urlencoded',
                                                               'content-length' => 0
                                                             }, 'HTTP::Headers' ),
                                        '_method' => 'POST'
                                      }, 'HTTP::Request' )
               }, 'HTTP::Response' );


Please, I pray for your help on getting this problem solved.


Thanks in advance

Replies are listed 'Best First'.
Re: 500 error on a simple request
by blue_cowdawg (Monsignor) on Sep 24, 2014 at 16:07 UTC
        '500 Can\'t connect to (Bad hostname \'\')

    This looks to be a DNS issue and not a Perl issue. If the hostname cannot be resolved have a word with your network support folks and find out why. You could to a

    and see if it resolves from the command line.

    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; Blog: Warning: No political correctness allowed.

      Here's result from nslookup and also resolv.conf file.

      It seems the first nameserver in the list doesn't work but the second does.

      Does that mean my perl program always uses the first nameserver from the list?

      Any suggestions what I should do before getting to support guys?

      $ /usr/sbin/nslookup
      ;; Got recursion not available from, trying next server

      Non-authoritative answer:

      $ more /etc/resolv.conf
      options timeout:2 retrans:1 retry:1
      domain xxxxxxxx


        Do the same on the other two systems, present everything to Support and ask them if they have been messing with the system that has stop working properly.

        Ask nicely, it's best to stay friends with Support


Re: 500 error on a simple request
by ikegami (Patriarch) on Sep 24, 2014 at 16:08 UTC
    Bad hostname '' means it wasn't able to resolve the into an IP address.