nightwatch: Nightwatch: Error retrieving a new session from the selenium server

i have 2 PC: server with Redhat 7.2 and my local PC with Ubuntu 15.10. When i run tests in Ubuntu (test work on remote machine with windows OS) all it’s OK. But if i run in Redhat 7.2 i get this error:

Error retrieving a new session from the selenium server Error: connect ETIMEDOUT 54...*:4444 at Object.exports._errnoException (util.js:856:11) at exports._exceptionWithHostPort (util.js:879:20) at TCPConnectWrap.afterConnect as oncomplete Selenium server is not running. Connection refused! Is selenium server started?

my json file:

{
  "src_folders" : ["tests"],
  "output_folder" : "logs",

  "selenium" : {
    "start_process" : true,
    "log_path" : "logs",
    "port" : 4444
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "http://localhost",
      "selenium_port"  : 4444,
      "selenium_host"  : "54.*.*.*",
      "silent": true,
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities": {
        "browserName": "firefox",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    }
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 45 (2 by maintainers)

Most upvoted comments

You should set “start_process” to false if you are connecting to a remote selenium server.

I updated my chromedriver exe and selenium standalone server to the lastest version and it fixed it

I set “marionette”: false, and it worked! Opened Firefox and ran the test. This frustrated the hell out of me.

I have the same issue. nightwatch (selenium + chrome) works when run manually via npm script, but the selenium server won’t start if it is run via gitlab CI runner. Any news?

I had same error. image Nightwatch.json had following setting image It worked after making following changes. i.e. “browserName” : “chrome”, image

@serejajar I found the same issue. Please mention what is the proper solution you found.

I found that this happens when I run npm run e2e-setup which downloads the latest version of selenium and chrome driver.

My solution was to update the version of chromedriver and selenium in my nightwatch.json since they no longer matched the versions that were installed by the e2e-setup script.

I was able to solve mine by setting webdriver.chrome.driver: "" in the cli_args property in nightwatch.json

I do not know if this helps because I’m a complete noob. But when I changed

“cli_args”: { “webdriver.chrome.driver”: “lib/drivers/chromedriver” }

to:

“cli_args”: { “webdriver.chrome.driver”: “lib/drivers/chromedriver.exe” }

It worked for me.

please make sure your path end with “…//selenium-server-standalone-3.4.0.jar” and the start_process is “true”
here is my setting image

Set “marionette” parameter to “false” to get away with the error : Error retrieving a new session from the selenium server

Connection refused! Is selenium server started? { Error: socket hang up at createHangUpError (_http_client.js:345:15) at Socket.socketCloseListener (_http_client.js:377:23) at emitOne (events.js:120:20) at Socket.emit (events.js:210:7) at TCP._handle.close [as _onclose] (net.js:545:12) code: ‘ECONNRESET’ }

For firefox as browserName, I had to set marionette to false and, for chrome I had to set it to true. Then it worked in both the test environments (default used firefox and chromium-browser was used in chrome profile)

This is almost always a invalid combination of the browser-version, the appropriate driver and the used selenium version.

@andre0799 suggestion on updating selenium server standalone, geckodriver and chromedriver to the latest version fixed it for me. You may want to try that @jbui2006.

I just tried nightwatchjs today (December 17, 2016) and I kept getting the error:

~/playground/nightwatch-0.9.11 ᐅ nightwatch --verbose test/sampletests/demotest1.js

[Digg] Test Suite

digg module is disabled, skipping…

[Github / Github] Test Suite

Running: Demo test GitHub INFO Request: POST /wd/hub/session

  • data: {“desiredCapabilities”:{“browserName”:“firefox”,“javascriptEnabled”:true,“acceptSslCerts”:true,“platform”:“ANY”,“name”:“Github / Github”}}
  • headers: {“Content-Type”:“application/json; charset=utf-8”,“Content-Length”:138}

Error retrieving a new session from the selenium server

Connection refused! Is selenium server started? { [Error: connect ECONNREFUSED 127.0.0.1:4444] code: ‘ECONNREFUSED’, errno: ‘ECONNREFUSED’, syscall: ‘connect’, address: ‘127.0.0.1’, port: 4444 }

~/playground/nightwatch-0.9.11 ᐅ

Strange thing, I cloned one of my co-worker’s repo on the same Mac computer and the same sample test ran just fine.

I copied the package.json & nightwatchjs.json from my co-worker’s repo to mine, I still faced the same error.

Any suggestion?

“cli_args”: { “webdriver.chrome.driver”: “lib/chromedriver.exe” }

by adding .exe for chromedriver it got fixed for me

npm i chromedriver@latest -D

I ran into some issues with chrome recently with the latest 3.8 release. I’m not sure if this will fix your issue but mine was fixed by changing the config as follows: chromeOptions -> goog:chromeOptions

example config:

    chrome: {
      desiredCapabilities: {
        browserName: 'chrome',
        javascriptEnabled: true,
        acceptSslCerts: true,
        'goog:chromeOptions': {
          args: [
            '--no-sandbox',
            '--disable-popup-blocking',
            '--disable-infobars',
            '--enable-automation',
          ],
          useAutomationExtension: true,
          extensions: [
            common.encode('./extensions/ModHeader_v2.1.2.crx'),
            common.encode('./extensions/Private-Internet-Access_v1.4.0.crx'),
          ],
          prefs: {
            credentials_enable_service: false,
            profile: {
              password_manager_enabled: false,
            },
          },
        },
      },

regarding firefox though - still getting an error that I am unable to get a session like others mentioned above.

I had the same issue, I tried a few different selenium-server-standalone.jar files as server_path and got different errors on most, in the end I fixed the issue by just putting “desiredCapabilities” inside of “desiredCapabilities.default” as highlighted in this screenshot.

image

if you want firefox i think you could just change “browserName” to ‘firefox’, I have not tried this though.

I hope this works for you too!

I have the same error, when I’m trying to run tests using firefox browser. I don’t have any problems with: IE, Edge and Chrome. Do you guys already found a solution for this bug?

This does seem to be a re-occuring problem. Running locally the only fix I have found is switching to another port.