Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python urllib2 giving "network unreachable error" if the URL is https

I am trying to fetch some urls using urllib2 library.

a = urllib2.urlopen("http://www.google.com")
ret = a.read()

Code above is working fine, and giving expected result. But when I make the url https, it gives "network unreachable" error

a = urllib2.urlopen("https://www.google.com")
urllib2.URLError: <urlopen error [Errno 101] Network is unreachable>

Is there any problem with ssl? My python version is Python2.6.5. I am also behind an academic proxy server. I have the settings in bash file. Anyway, since http is opening proxy shouldn't be the problem here.

like image 987
Sravan Avatar asked Dec 27 '25 16:12

Sravan


1 Answers

Normally the issue in cases like this is the proxy you are behind having an out of date or untrusted SSL certificate. urllib is fussier than most browsers when it comes to SSL and this is why you might be getting this error.

like image 168
Jharwood Avatar answered Dec 30 '25 05:12

Jharwood



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!