Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

LWP Error '500 Can't connect to (Network is unreachable)'

by vcTheGuru (Chaplain)
on Dec 05, 2012 at 03:01 UTC ( #1007182=perlquestion: print w/replies, xml ) Need Help??
vcTheGuru has asked for the wisdom of the Perl Monks concerning the following question:


I am getting a 'Network Unreachable' error while trying to download via YouTube API to my server. I use a subroutine

sub getWebContent{ my $url = shift; my $key = shift; return unless $url; my $ua = LWP::UserAgent->new; $ua->agent("Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/2012040321 +1507 Firefox/12.0"); my $req = HTTP::Request->new(GET => $url); $req->content_type('application/x-www-form-urlencoded'); $ua->ssl_opts('verify_hostname' => 0); if($key){ $req->authorization_basic($key, $key); } print "<pre>".$ua->request($req)->as_string."</pre>"; my $res = $ua->request($req); if ($res->is_success) { return $res->content; } else { print $res->status_line, "<br>$url\n<br>\n$key\n<br>\n \n"; return; } }

I get

500 Can't connect to (Network is unreachable)
Content-Type: text/plain
Client-Date: Wed, 05 Dec 2012 02:51:52 GMT
Client-Warning: Internal response

Can't connect to (Network is unreachable)

LWP::Protocol::https::Socket: connect: Network is unreachable at /usr/local/share/perl5/LWP/Protocol/ line 51.

I tried multiple options available in the Monastery and many other forums and failed.

Please Help!

UPDATE: 1. When I use CURL or wget, I could download the data from YouTube. The Problem is with YouTube API only. It works fine with Bing. Youtube sends me the Certificate issued to multiple hosts on Google.

UPDATE : Fixed by force install LWP::Protocol::https::Socket Thanks to all.


  • Comment on LWP Error '500 Can't connect to (Network is unreachable)'
  • Download Code

Replies are listed 'Best First'.
Re: LWP Error '500 Can't connect to (Network is unreachable)'
by Anonymous Monk on Jul 17, 2016 at 14:04 UTC
    Thank you for your UPDATE , i fixed it by updating LWP::Protocol::https::Socket with cpanm. previous package installed by yum in EL6 .
Re: LWP Error '500 Can't connect to (Network is unreachable)'
by Anonymous Monk on Dec 05, 2012 at 04:07 UTC

    Please Help!

    Use a module from cpan with GOOGLE in the name that uses the google API, chances are google wont block you if you do that

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1007182]
Approved by mbethke
[marto]: "Eugenie Scott, executive director of the National Center for Science Education, dubbed this approach the Gish gallop, describing it as "where the creationist is allowed to run on for 45 minutes or an hour, spewing forth torrents of error that the
[marto]: evolutionist hasn't a prayer of refuting in the format of a debate." She also criticized Gish for failing to answer objections raised by his opponents"
[erix]: one would hope evolutionists haven't any prayers anyway
[marto]: obviously someone could be religious, but not creationist
[erix]: "Nothing in Intelligent Design makes sense except in the light of Creationism" <-- I made that one up myself (free after Dobzhansky )
[erix]: yes. Deplorable marto, deplorable.
[marto]: the situation seemed similar to this one, majority of the contributrions are nonsense, doesn't address any questions ...
[marto]: meh, I've been called worse :P

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2017-07-28 15:43 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (431 votes). Check out past polls.