Forums

iPython Notebooks & Internet Access (Paid Account)

Hiya,

I've tried searching and can't seem to find an answer for my issue :(

I have a paid account (Hacker) and was hoping to create iPython Notebooks to do some stuff but can't get them to grab content from other sites, such as the following which uses 'requests'...

import requests
url = 'https://www.pythonanywhere.com'
response = requests.get(url)
html = response.content
print html

...or this one with 'urllib'...

import urllib
url = 'https://www.pythonanywhere.com'
html = urllib.urlopen(url)
print(html.read())

The problem is, that I get a connection error regardless of what URL I throw in there (in both cases):

ConnectionError: ('Connection aborted.', error(111, 'Connection refused'))

Is this a limitation of the account with regard to Notebooks or am I missing something here? The same code works fine from a console.

Thanks in advance for any tips!

Hb.

That's odd. I just tried your code in iPython 2.7 and it's fine here.

Maybe try with http:// instead of https://, just as an experiment?

Could you try to restart the kernel for that notebook and see if that helps.

Thanks for the help, I've restarted kernels, created a new notebook file, killed all running process and also tried http/https... Nothing seem to make any difference and the notebook code still can't get out.

For testing, I also tried with 'requests' and a white listed site 'www.apple.com' (just in case there is something screwy with my paid account) and it gives me a different connection error:

ConnectionError: ('Connection aborted.', error(101, 'Network is unreachable'))

I also dumped the proxy settings from within the notebook and it returned 'None'.

Cheers,

Hb.

It looks like there's a bug that sometimes prevents the necessary network rules from being applied. I have applied them for your account and things should be working for you now.

Perfecto, all is good :)

Thanks Glenn!

switched from free to paid plan and have a similar issue.

i can't use network (with pycurl or !curl) from a notebook file.

  • error: (7, 'Failed to connect to www.apple.com port 80: Connection refused') in pycurl
  • curl: (7) Failed to connect to www.apple.com port 80: Connection refused with !curl

however, those same calls can be done from bash console, and python/ipython within a bash console.

greets, s

I have applied the settings for your account and you should be able to access the internet now.

thanks glenn, works fine now.