getting URLError: <urlopen error [Errno 111] Connection refused> in selenium webdriver using python in phantomjs

python, selenium

Solution

Having Googled this, it seems to happen unpredictably but after I've made a few requests with Selenium / Phantom. If I create a new webdriver with `driver = webdriver.PhantomJS()` then I'm able to continue making requests. I suggest others use the same workaround.

Problem

I'm using Selenium Webdriver in Python. While running the script in headless browser(phantomjs) I'm getting an URLError: ``` <urlopen error [Errno 111] Connection refused> ``` Any one can please help to handle this?

Original source