• Register
0 votes
376 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

Please log in or register to answer this question.

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 4 views
4 views
Problem: I have installed ubuntu terminal in window 10. It's work fine but when I install gedit or any other application then these applications installed successfully but I can not open it. Whenever I tried it gives me the Error mentioned below. "Failed to connect ... file or directory Unable to init server: Could not connect: Connection refused (gedit:4821): Gtk-WARNING **: cannot open display:"
asked Apr 25 muktaa 34.4k points
0 votes
1 answer 5 views
5 views
Problem: What caused the error, " PostgreSQL error" Could not connect to server: No such file or directory" " ?
asked Apr 21 zayed1 58.7k points
0 votes
1 answer 12 views
12 views
Problem: I'm trying to run psql on my Vagrant machine, but I get this error: psql: could not connect to server: No such file or directory
asked Mar 31 ummesalma 29.2k points
0 votes
1 answer 4 views
4 views
Problem: While restart mongodb server using below command. its showing error like : Failed to restart mongod.service: Unit mongod.service not found. sudo service mongod restart
asked Apr 24 anika11 32k points
0 votes
1 answer 8 views
8 views
Problem: Is there anyone who can help me out to fix a problem?My computer is showing an error.
asked Mar 28 ashik 14.6k points
1 vote
1 answer 52 views
52 views
Problem : HELP! I need help understanding this error: open failed: ENOENT (No such file or directory) When I try to create a file to save pictures from the camera, it turns out that I can't create the file.
asked Mar 24 Sabbir Hossain 14.6k points
0 votes
1 answer 25 views
25 views
Problem: I am trying to compile ARM code in Ubuntu 12. Everything is working fine when I put the code in the local directory. But when I put the code in cited mount directory error shows up: Sh: 0: getcwd() failed: no such file or directory
asked Mar 24 ummesalma 29.2k points
0 votes
1 answer 686 views
686 views
I'm getting something like this. Can anyone please tell me how to fix this. C:\Users\krush\Documents\ML using Python>pip install pocketsphinx Collecting pocketsphinx Using cached pocketsphinx-0.1.3.zip Building wheels for collected packages: pocketsphinx Running setup.py bdist_wheel for pocketsphinx: started ... ------------------------- Command "C:\Users\krush\Anaconda3\python.exe -u -c "impor
asked Oct 25, 2020 psandprop 2.4k points
0 votes
1 answer 108 views
108 views
I'm trying to install spaCy using pip install spacy but I'm getting the following error .. I have VS 2015 installed, and I have the following Python install .. 3.5.2 |Anaconda 2.5.0 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 ... others. This is not a unique problem to this specific library but more generally anytime I try to install Python libraries that need C to build on Windows.
asked Oct 24, 2020 psandprop 2.4k points