Selenium Connection Refused on Apache Web Server

261 Views Asked by At

I have an app that runs selenium on user requested URLs. The app works completely fine on the django dev server on an aws ec2 instance. Deploying the same project--on the same server--on an apache prod web server creates the following error (if I allow django debug to remain on):

Exception Type: TimeoutException at /
Exception Value: Message: connection refused

I am using the geckodriver with firefox v. 71 and the newest geckodriver. I point to the absolute path of the geckdriver:

from selenium import webdriver
options = webdriver.FirefoxOptions()
options.headless = True
driver = webdriver.Firefox(options=options, executable_path=path_to_driver, service_log_path=path_to_log)
...

Currently I am not using pyvirtualdisplay whereas everything worked fine on the same server in dev. When I did try to use pyvirtualdisplay I had the same results.

I think it may be a permissions issue with apache and the webdriver, but I'm not sure. I did grant apache executable permissions to the geckodriver:

-rwxrwxr-x 1 ubuntu www-data 7008696 Jan  8 03:02 geckodriver

Any thoughts?

0

There are 0 best solutions below