• Register
0 votes
88 views

Problem :

I am trying to develop some selenium tests which should run with headless firefox but the following error suddenly popped up in my server.log file when I was trying to connect to the webdriver via following command:

driver = webdriver.Firefox(firefox_profile = profile, log_path = logfile)

Please find below the error:

1518520162032   geckodriver::marionette INFO    Starting browser /usr/bin/firefox with args ["-marionette"]

Failed to connect to Mir: Failed to connect to server socket: No such file or directory

Unable to init server: Could not connect: Connection refused

Error: cannot open display: :1137

I have not done any changes in my code. It was working fine before this error came. How can I fix the above error???

My software spec as below:

python 2.7.12, Firefox: Mozilla Firefox 57.0.3, geckodriver: 0.19.1, selenium: 3.8.0

6 5 3
7,540 points

1 Answer

0 votes

Solution :

Your error is giving all required information:

Failed to connect to Mir: Failed to connect to server socket: No such file or directory

Unable to init server: Could not connect: Connection refused

Error: cannot open display: :1137

This error indicates that your DISPLAY property was not set properly.

Please add the below configuration in the .bashrc :

export DISPLAY=:0

For the Gnome on Ubuntu 16.04, the correct value should be DISPLAY=:1 (and not DISPLAY=:0)

The problem must be happening due to env_keep variable from /etc/sudoers. So the permanent solution should be adding the below line at the end of  /etc/sudoers by using gedit or using sudo visudo as follows:

Defaults env_keep+="DISPLAY"

 After above changes your issue will be resolved.

9 7 4
38,600 points

Related questions

0 votes
1 answer 5 views
5 views
I keep on recieving this error in my php project “failed to open stream: no such file or directory” each time I need to include a php file. What is the best practice to include another php file from a different folder? Is it also possible to include a php file located in a different domain?
asked Oct 12 azriel 360 points
0 votes
1 answer 4 views
2 votes
1 answer 1.4K views
1.4K views
Problem: When I try to run the below command on my command prompt: python get-pip.py It shows the following message: C:\Users\ASUS>python get-pip.py python: can't open file 'get-pip.py': [Errno 2] No such file or directory How can I have pip installed in my system. Then why am I getting this error message and why I can not open this file. Thanks in advance.
asked May 6 samhaz 5k points
0 votes
1 answer 1.1K views
1.1K views
I was creating a new project in django. Firstly I installed django in my system but when I run the command : python manage.py runserver It does not work It shows a message : python: can't open file 'manage.py': [Errno 2] No such file or directory ... django and I started a project by running the command : django-admin startproject Utility Why am I seeing this error message, do anyone know?
asked Mar 18 LizzyM 6.1k points