1

I am running Selenium file on Amazon AWS Ubuntu Server, but I am getting the following error on the below line:

driver = webdriver.Chrome();

The error says:

selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127 

I have tried many solutions but it is still not working (How to fix Selenium WebDriverException: The browser appears to have exited before we could connect?)

I have also tried with:

driver = webdriver.Firefox();

and in Firefox, I am getting the following error:

selenium.common.exceptions.WebDriverException: Message: connection refused

Can anyone help me?

Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
Gopal Chitalia
  • 430
  • 4
  • 18

3 Answers3

1

Do you install chromedriver or geckodriver on the server? Your chromedriver should be in all of following directory:

chromedriver: /usr/bin/chromedriver /bin/chromedriver 
/usr/local/bin/chromedriver /usr/local/chromedriver

Or, you can paste path directly: driver = webdriver.Chrome(path='./chromedriver').

Also, use PyVirtualDisplay.

Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
amarynets
  • 1,765
  • 10
  • 27
1

Since its Amazon AWS please check if Chrome is installed, if not please install from link.

Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
user8672807
  • 124
  • 5
1

Your problem is due to no display in AWS. When you are trying to execute the command driver = webdriver.Firefox() or driver = webdriver.Chrome() the system tries to launch a Firefox or Chrome browser but because you do not have access to the display in remote access so it is crashing there.

Follow the steps given at this blog and you can create a virtual display to buffer frames. Then your script will not crash due to this problem

abggcv
  • 461
  • 5
  • 20