Nightwatch.js chromedriver error "Error connecting to localhost on port 9515"

Viewed 2050

I have come across this issue multiple times when helping a new hire and each time i have to go through different steps each time to rediscover the fix. These are things that have made it work, unfortunately i am slightly less technical than I used to be and dont exactly know why they work, but they do. Hence i have decided to put this out here, hoping my next new hire will come across this when searching for a fix.

⠋ Connecting to localhost on port 9515...
Starting ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b1382549290d-refs/branch-heads/4280@{#1761}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
⚠ Error connecting to localhost on port 9515.
1 Answers

Here is a list of things to try:

  1. Upgrade to the lastest version of Chromedriver by deleting node_modules, update the version of chromedriver in package.json and npm install. An upgrade has fixed such an error message 3 out of 5 times that i have seen it happen.

  2. Check if a chrome driver process is already running on the system and has placed a lock on the port that you are trying to access. Sometimes, chromedriver does not quit when it stops in error, as a result the port from your config is not available and the subsequent runs fail.

  • On a mac follow these steps :

    ps -ax | grep -i chromedriver

  • Find the PID of the process ( usually an integer in the first column ), then :

    kill < PID >

  1. In nightwatch.config.js ( or figure out which config file is being used from your package .json script key ) add :

       selenium: {
     start_process: true }
    

If there is already a selenium object, add a comma after the last k-v pair and append this k-v pair to it.

Related