[firefox] Webdriver Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms

I have box where I run tests. It seems like Jenkins would ssh in and execute commands described in the specific job that's running.

Here I am trying to run my Selenium Webdriver tests, but it tells me that I have errors in launching firefox. The end idea is to run the webtests on this box entirely, and also take some screenshots of errors.

I am using selenium-java-2.25.jar, firefox 10, linux OS.

The funny thing is that I can ssh in manually into the box, temporarily copy the magic cookie from another user on the box (to get an X tunnel), do an export DISPLAY=mydisplay:1.0, then launch my selenium tests using ant. And this will bring up firefox and the tests just fine.

There are various threads here that seem to have the exact same problem, and I think I've tried most of them. Here is what I've done:

  • Reboot the box, log back in with VNC.

  • Placed a bash script in Jenkins to run before running selenium tests. The bash script basically just does an export DISPLAY=mydisplay:1.0. It also executes xclock. This works as I can see xclock being displayed in the VNC.

  • iptables have been turned off

  • firefox is correctly located in /usr/bin/firefox

  • sshd_config shows having X11Forwarding as true.

  • Supposedly downgrading firefox helped some people, but I do not wish to do this. Webdriver should support FF 10 anyway.

However, none of the above solves the problem.

It doesn't seem like port 7055 on localhost even exists:

netstat -an | grep 7055 - Nothing prints

This is what my /etc/hosts says:

  1 127.0.0.1               localhost.localdomain localhost
  2 ::1             localhost6.localdomain6 localhost6

Perhaps it has something to do with localhost:7055 not existing? I am unsure where to go from here. still, why does the error output say it's looking for display: :0.0 when I've specified mydisplay:1.0?

And finally the error output I receive:

[testng] org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
[testng] Xlib: connection to ":0.0" refused by server
[testng] Xlib: No protocol specified
[testng] 
[testng] Error: cannot open display: :0.0
[testng] Xlib: connection to ":0.0" refused by server
[testng] Xlib: No protocol specified
[testng] 
[testng] Xlib: connection to ":0.0" refused by server
[testng] Xlib: No protocol specified
[testng] 
[testng] Xlib: connection to ":0.0" refused by server
[testng] Xlib: No protocol specified
[testng] 
[testng] Error: cannot open display: :0.0
[testng] 
[testng]    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:109)
[testng]    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:245)
[testng]    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:109)
[testng]    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:185)
[testng]    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:178)
[testng]    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:174)
[testng]    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)
[testng]    at com.test.webtest.browser.BrowserFactory.createBrowser(BrowserFactory.java:24)
[testng]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[testng]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[testng]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[testng]    at java.lang.reflect.Method.invoke(Method.java:601)

This question is related to firefox selenium jenkins x11 selenium-webdriver

The answer is


This happens because of old versions. Just update the browser to latest version and update the selenium webdriver package to latest version.


Get the latest Selenium jars (2.30) for FireFox 19

You can download the latest jars (2.31 as of writing) here: https://code.google.com/p/selenium/downloads/list


Don't know if you resolved this problem, but I have just resolved the same issue from the other side.

It appears Selenium and Firefox have difficulty talking to each other - I suspect Firefox 'evolve' changes over a number of releases, so backward and forward compatibility are not always guaranteed, and incompatibility always seems to generate the same error.

My problem started when I moved from FF 15 to FF 16. Running on Ubuntu, this happens auto magically along with other upgrades but I believe this was the critical change.

The problem was resolved by moving from Selenium 2.24.1 to Selenium 2.25.0

As the selenium change is just download the jar file and run it instead of the old one,it's worth trying this as a quick and easy troubleshooter - if it doesn't help, just switch back. In your case, I'm not sure which version of Selenium to try, but I think 2.24 should work with FF 10.

Another issue I have found in the past is that Firefox would not run as root on Ubuntu. This happens if Selenium is running as a service, or possibly if it is fired up from a bash script or cron job. This may explain why it runs for you but not for Jenkins.


For solve this issue, use new jar files available on http://docs.seleniumhq.org/download/. As respective to java, C#, php etc...Firefox 27.0.1 require 2.39.0 of driver version.


I got the same error; I've used selenium-java version 2.25.0 and Firefox vresion 18.0.2; I've changed the version of selenium-java to 2.30.0 and now works.


It happens on different versions of ff. I'm using latest ff version 39 by using selenium-server-standalone-2.41.0.jar and selenium-java-2.41.0.zip which shows same error.

Get the latest server and client jar files here for the compatibility i used server and client versions 2.47.0 and 2.47.1 respectively. And Boom! It worked.


This is how it's behaved when I used static property of IWebDriver and call it from multiple test methods.

public class LanguageMenu
{
    private static IWebDriver drv;

    static LanguageMenu()
    {
       drv = Driver.Instance;
    }
    ...

    public static void English()
    {
        drv.FindElement(By.Id("mvc_lang_en"));
        el.Click();
    }

    public static void Rusian()
    {
        ...
    }

    ...
}

Like

 [TestMethod]
 public void Language_SwitchTo_English()
 {
     LanguageMenu.English();
     Assert.IsTrue(ContactPage.IsAt("Contact"));
 }

 [TestMethod]
 public void Language_SwitchTo_Rusian()
 {
     LanguageMenu.English();
     Assert.IsTrue(ContactPage.IsAt("???????"));
 }

Solution

For each calling test methods create new instance of Driver

 private static void English()
 {
            var drv = Driver.Instance;
            var el = drv.FindElement(By.Id("mvc_lang_en"));
            el.Click();
 }

Just install Xvnc Plugin in Jenkins. The problem should be solved.


Update selenium jars if our selenium script is not executing. Currently i am using selenium-java-2.43.0-srcs

Now it is working fine


Me too had the same problem but issue is resolved after downgrading firefox version to 35.0.1 and my selenium version is 2.43


I had Firefox 47 and Selenium 2.53, and i got the same error. My solution was change Firefox 47 to Firefox 46, the problem was solved.


I had the same problem today. To fix I downgraded firefox version 51 to 47 and it's working.

Note: I'm using a Linux Ubuntu Mate, in a Virtual Box, with host being another Ubuntu Mate. All OS are 64 bits and firefox also.


I had the same issue with firefox 38.

After using following version dependencies, I could resolve the issue.

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.53.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>2.53.0</version>
    </dependency> 

This issue has haunted me for long time and I have seen one working solution in case of Firefox was to use the upgraded firefox driver.

  • If your firefox upgrades are happening automatically than you may face this problem once in a while. Looks like Firefox guys are developing too fast, or they do not care about backward compatibility.

  • Every time I see this issue on my old scripts I check if the firefox version has changed since - most of the times it is.

  • Then I go to maven repo for selenium firefox driver repo - http://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-firefox-driver and download the latest version.

  • or update my pom.xml (if maven is used) with new version of firefox driver right now its - 2.40.0

  • There is no easy way to avoid this issue unless you really explicitly block the automatied update from firefox (You can do this (On Mac) in preferences - Advanced - Update - Select "Check for updates, but let me choose whether to install them")

  • If your scripts are running on a automated mode then you may want to disable updates. However this may create other issues. Since most people/user may have firefox updates enabled by default. So your application is not really being tested on any later versions.


I too was stuck at this error for three days and finally figured it out.You can view the answer I have given here .This is browser and selenium server compatibility issue. I hope this helps.You can check browser compatibility from this link


Solution -

1) Upgrade your Selenium Server i.e. selenium jar "selenium-server-standalone-2.xx.x.JAR" TO "selenium-server-standalone-2.45.0.JAR"

2) Upgrade your Selenium Client Driver i.e. selenium libs folder "selenium-java-2.xx.x" TO "selenium-java-2.45.0"

3) Check and Install compatible Firefox version

Refer - Download updated selenium libs & jar i.e. Version 2.45.0

This will RESOLVE your problem.. Cheers !!


The problem with the script is that the environment used for the script is not the same as the one used for your tests, so setting the environment variables there does nothing for your tests.

To properly set the variable you need to set it in Jenkins. Go to Manage Jenkins>Manage Nodes>Master>Configure. Check the Environment variables check box, then enter DISPLAY in the name box, and set the value to :1.0.

Additionally you'll need to set permissions, try disabling your xhost access controls using xhost + in the terminal.


I resolved this issue by downgrading my Firefox to an older version that had previously worked well with Selenium-WebDriver. In my case, I had to downgrade back to Firefox 18 and this version worked with Selenium 2.27

Here is the link to get older versions of firefox: https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/


I had a similar issue. Maybe this answer will help you as well.

It looks like you have two different errors going on:

  1. Unable to connect to host 127.0.0.1 on port 7055
  2. Error: no display specified

The reason for the Unable to connect error is that the version of Selenium Server does not know how to work with the newer version of Firefox. You need to download a newer version of the Selenium Server that supports the newer version of Firefox.

The reason for the Error: no display specified error is that Firefox is being launched, but there is no X server (GUI) running on the remote host. You can use X11 forwarding to run Firefox on the remote host, but display it on your local host. On Mac OS X, you will need to download XQuartz in order to use X11 forwarding.


I think this could be a problem of display. If you do not have GUI in the box, then launching firefox from selenium webdriver would give this error.

To resolve this, first install Xvfb [yum install Xvfb -y]( a virtual display driver) in the box. Then run your test from jenkins with xvfv-run -a -d <your test execution command>. This will launch the browser in a virtual display buffer. Also it is capable of getting screenshots using selenium webdriver.


You need to check the browser compatibility before opting to test with Selenium:

https://github.com/SeleniumHQ/selenium/blob/master/java/CHANGELOG

This might help to answer the above question.


Installed Firefox Setup 18.0.exe it works for me


I also faced the same problem. Whenever we or webdriver opens up the FF browser will check for the updates if any. In that case, i will try to update during the execution time and then you will be getting the error even if it is updated properly just because you have not update the Selenium version appropriately.

Navigate to "http://docs.seleniumhq.org/download/" and download the latest version. Now go and check, the problem would be resolved, indeed. :)


I got the same error "selenium_Unable to connect to host 127.0.0.1 on port 7055" Solution : I've used selenium-java-2.48.2 with Firefox version 43.0.1 and now its working well.


Update selenium jars, download selenium 2.31.0

This issue has been resolved by the selenium guys

This was a compatibility issue.

Cheers


I had the exact same problem running docker but I found the solution in the log preceding the error you've mentioned.

selenium_1  | 2016-11-11 11:19:34,498 DEBG 'xvfb' stderr output:
selenium_1  | (EE)
selenium_1  | Fatal server error:
selenium_1  | (EE) Server is already active for display 99
selenium_1  |   If this server is no longer running, remove /tmp/.X99-lock
selenium_1  |   and start again.
selenium_1  | (EE)

I've followed the advice and problem has been sorted out.


On Windows: Check as well the "bitness" of your Firefox. Firefox 43.0.1 64bit does not work with Selenium 2.50.0. Working well with Firefox 43.0.1 32bit ...


Adding to the knowledge base. We had the same issue on Bamboo. The problem was resolved by using the Environmental Properties on Bamboo.

DISPLAY=":1"

Adding the value as system properties in the pom.xml, or the command line did not work.


Just Restart the terminal. Terminal is hanged nothing else. Everything will work fine after that


Examples related to firefox

Drag and drop menuitems Class has been compiled by a more recent version of the Java Environment Only on Firefox "Loading failed for the <script> with source" Selenium using Python - Geckodriver executable needs to be in PATH Selenium using Java - The path to the driver executable must be set by the webdriver.gecko.driver system property How to use the gecko executable with Selenium Selenium 2.53 not working on Firefox 47 Postman addon's like in firefox Edit and replay XHR chrome/firefox etc? How to enable CORS on Firefox?

Examples related to selenium

SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81 session not created: This version of ChromeDriver only supports Chrome version 74 error with ChromeDriver Chrome using Selenium Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser Class has been compiled by a more recent version of the Java Environment How to configure ChromeDriver to initiate Chrome browser in Headless mode through Selenium? How to make Firefox headless programmatically in Selenium with Python? element not interactable exception in selenium web automation Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click How do you fix the "element not interactable" exception?

Examples related to jenkins

Maven dependencies are failing with a 501 error Jenkins pipeline how to change to another folder Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock groovy.lang.MissingPropertyException: No such property: jenkins for class: groovy.lang.Binding How to solve npm install throwing fsevents warning on non-MAC OS? Run bash command on jenkins pipeline Try-catch block in Jenkins pipeline script How to print a Groovy variable in Jenkins? Jenkins pipeline if else not working Error "The input device is not a TTY"

Examples related to x11

Forward X11 failed: Network error: Connection refused Can you run GUI applications in a Docker container? how to add the missing RANDR extension Webdriver Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms Error: cannot open display: localhost:0.0 - trying to open Firefox from CentOS 6.2 64bit and display on Win7 Java Can't connect to X11 window server using 'localhost:10.0' as the value of the DISPLAY variable How can I specify a display? "No X11 DISPLAY variable" - what does it mean? How to check if X server is running?

Examples related to selenium-webdriver

SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81 Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser How to configure ChromeDriver to initiate Chrome browser in Headless mode through Selenium? How to make Firefox headless programmatically in Selenium with Python? Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click How do you fix the "element not interactable" exception? Scrolling to element using webdriver? Only local connections are allowed Chrome and Selenium webdriver Check if element is clickable in Selenium Java