Forums

urlopen error [Errno 111] Connection refused

I am using selenium and I am getting this error when I am trying to connect to any external website. I am on the web developer plan.

Can anybody help regarding this?

OK, I have a web account too, and my access is OK. Let's see if we can work this out-

What is the command you are using?

Does it work if you use a different website?

Does it work in the console?

Also, could you post the code? If it's something you don't want to post publicly here, then I can take a look at it in your private file storage if you're happy with that and you tell me which file it is.

Here is the code I am using :

from selenium import webdriver
driver = webdriver.PhantomJS()
driver.get("www.yahoo.com")

Hmm, that's odd -- if I try that code, I get this:

>>> driver = webdriver.PhantomJS()
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/webdriver.py", line 50, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/service.py", line 63, in start        raise WebDriverException("Unable to start phantomjs with ghostdriver.", e)
selenium.common.exceptions.WebDriverException: Message: 'Unable to start phantomjs with ghostdriver.' ; Screenshot: available via screen

Perhaps you could try using Xvfb and Firefox as per this blog post? Alternatively, could you post the complete stack trace you're seeing?

I have the path of the phantomjs excetutable passed to the PhantomJS constructor

OK. Did you install PhantomJS yourself? And could you post the full stack trace you're getting?

Hey, I had a play with PhantomJS on PythonAnywhere the other day, and IIRC it didn't work for me either. It'll be something to do with our sandboxing environment.

I haven't had any more time for it since, but my next plan was to use strace, and compare the output from it running (and failing) on PA, and it running and succeeding on a local PC. Then, try and figure out the place at which the PA one bugs out, it's usually some kind of missing file... @bazocjdi I don't suppose you'd feel up to doing that?

I should add -- the first time I used strace I felt way out of my depth, but I did it anyway and managed to make sense out of it...

Thanks, Harry!

@bazocjdi if you're not keen on helping us work out why PhantomJS won't work, then I recommend you use Firefox as per the blog post I linked to above -- everything's already installed for that and it's officially maintained as part of PythonAnywhere, so we're sure it works.

@giles: That was awesome. You linked back to the 3rd topic on this forum...it seems like a lifetime ago...☺

EDIT:

Okay, I'm an idiot...that was a BLOG entry, not FORUM....meh!!

If I remember correctly the third topic was a very silly bit of fake astroturfing anyway...

(Checks) Yes, it was.

At least we're well beyond that now!!

And we even have the PythonAnywhere merchandise store that we (not at all seriously) talked about back then.

I want my official PA non-wearable gear too. ͡° ͜ʖ ͡°

Perhaps we could do a mug?