title: How do I fix the error Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:50840 when using Cucumberjs?
body: <blockquote>
  <p>I have installed cucumberjs, chromedriver and selenium-webdriver.
  When I run npm run cucumber  I get the error</p>
  <p>Steins-MacBook-Air:todoguiacceptacceptancetest steinkorsveien$ npm run
  cucumber</p>
  <pre><code>&gt; todofrontenf@0.1.0 cucumber /Users/steinkorsveien/Development/todo/todoguiacceptacceptancetest
  &gt; cucumber-js
  
  P-----P----P----....(node:1152) UnhandledPromiseRejectionWarning: Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:50840
      at ClientRequest.&lt;anonymous&gt; (/Users/steinkorsveien/Development/todo/todoguiacceptacceptancetest/node_modules/selenium-webdriver/http/index.js:262:15)
      at ClientRequest.emit (events.js:314:20)
      at Socket.socketErrorListener (_http_client.js:469:9)
      at Socket.emit (events.js:314:20)
      at emitErrorNT (internal/streams/destroy.js:100:8)
      at emitErrorCloseNT (internal/streams/destroy.js:68:3)
      at processTicksAndRejections (internal/process/task_queues.js:80:21)
  (Use `node --trace-warnings ...` to show where the warning was created)
  (node:1152) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async
  </code></pre>
  <p>function without a catch block, or by rejecting a promise which was
  not handled with .catch(). To terminate the node process on unhandled
  promise rejection, use the CLI flag <code>--unhandled-rejections=strict</code>
  (see <a href="https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode" rel="nofollow noreferrer">https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode</a>).
  (rejection id: 3)
  (node:1152) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are
  not handled will terminate the Node.js process with a non-zero exit
  code.
  F----.(node:1152) UnhandledPromiseRejectionWarning: NoSuchElementError: no such element: Unable to locate element:
  {&quot;method&quot;:&quot;css selector&quot;,&quot;selector&quot;:&quot;*[id=&quot;loginLink&quot;]&quot;}
  (Session info: headless chrome=84.0.4147.125)
  at Object.throwDecodedError (/Users/steinkorsveien/Development/todo/todoguiacceptacceptancetest/node_modules/selenium-webdriver/lib/error.js:550:15)
  at parseHttpResponse (/Users/steinkorsveien/Development/todo/todoguiacceptacceptancetest/node_modules/selenium-webdriver/lib/http.js:565:13)
  at Executor.execute (/Users/steinkorsveien/Development/todo/todoguiacceptacceptancetest/node_modules/selenium-webdriver/lib/http.js:491:26)
  at processTicksAndRejections (internal/process/task_queues.js:93:5)
  at thenableWebDriverProxy.execute (/Users/steinkorsveien/Development/todo/todoguiacceptacceptancetest/node_modules/selenium-webdriver/lib/webdriver.js:700:17)
  at toWireValue (/Users/steinkorsveien/Development/todo/todoguiacceptacceptancetest/node_modules/selenium-webdriver/lib/webdriver.js:139:15)
  at /Users/steinkorsveien/Development/todo/todoguiacceptacceptancetest/node_modules/selenium-webdriver/lib/webdriver.js:190:16
  at forEachKey (/Users/steinkorsveien/Development/todo/todoguiacceptacceptancetest/node_modules/selenium-webdriver/lib/webdriver.js:184:9)
  at convertKeys (/Users/steinkorsveien/Development/todo/todoguiacceptacceptancetest/node_modules/selenium-webdriver/lib/webdriver.js:189:3)
  at thenableWebDriverProxy.execute (/Users/steinkorsveien/Development/todo/todoguiacceptacceptancetest/node_modules/selenium-webdriver/lib/webdriver.js:698:22)
  (node:1152) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async
  function without a catch block, or by rejecting a promise which was
  not handled with .catch(). To terminate the node process on unhandled
  promise rejection, use the CLI flag <code>--unhandled-rejections=strict</code>
  (see <a href="https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode" rel="nofollow noreferrer">https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode</a>).
  (rejection id: 4)
  F-F--P----</p>
  <pre><code>Failures:
  
  1) Scenario: Login failure # src/features/Login.feature:8
     ✖ Given I am currently loged out # src/features/steps/login.steps.js:6
         Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:50840
             at ClientRequest.&lt;anonymous&gt; (/Users/steinkorsveien/Development/todo/todoguiacceptacceptancetest/node_modules/selenium-webdriver/http/index.js:262:15)
             at ClientRequest.emit (events.js:314:20)
             at Socket.socketErrorListener (_http_client.js:469:9)
             at Socket.emit (events.js:314:20)
             at emitErrorNT (internal/streams/destroy.js:100:8)
             at emitErrorCloseNT (internal/streams/destroy.js:68:3)
             at processTicksAndRejections (internal/process/task_queues.js:80:21
  </code></pre>
  <p>My package.json looks like this</p>
  </blockquote>
  <pre><code>{ 
  
    &quot;name&quot;: &quot;todofrontenf&quot;,
        &quot;version&quot;: &quot;0.1.0&quot;,
        &quot;private&quot;: true,
        &quot;dependencies&quot;: {
          &quot;@babel/core&quot;: &quot;^7.10.5&quot;,
          &quot;@babel/plugin-transform-runtime&quot;: &quot;^7.11.0&quot;,
          &quot;@babel/preset-env&quot;: &quot;^7.10.4&quot;,
          &quot;@babel/preset-react&quot;: &quot;^7.10.4&quot;,
          &quot;@babel/register&quot;: &quot;^7.10.5&quot;,
          &quot;babel-jest&quot;: &quot;^26.2.1&quot;,
          &quot;cucumber&quot;: &quot;^6.0.5&quot;,
          &quot;dotenv&quot;: &quot;^8.2.0&quot;,
          &quot;expect&quot;: &quot;^26.4.0&quot;,
          &quot;jest&quot;: &quot;^26.2.1&quot;,
          &quot;react&quot;: &quot;^16.13.1&quot;,
          &quot;react-dom&quot;: &quot;^16.13.1&quot;,
          &quot;react-test-renderer&quot;: &quot;^16.13.1&quot;,
          &quot;selenium-webdriver&quot;: &quot;^4.0.0-alpha.7&quot;,
          &quot;winston&quot;: &quot;^3.3.3&quot;,
          &quot;winston-elasticsearch&quot;: &quot;^0.7.12&quot;
        },
        &quot;scripts&quot;: {
          &quot;cucumber&quot;: &quot;./node_modules/.bin/cucumber-js&quot;
        },
        &quot;eslintConfig&quot;: {
          &quot;extends&quot;: &quot;react-app&quot;
        },
        &quot;browserslist&quot;: {
          &quot;production&quot;: [
            &quot;&gt;0.2%&quot;,
            &quot;not dead&quot;,
            &quot;not op_mini all&quot;
          ],
          &quot;development&quot;: [
            &quot;last 1 chrome version&quot;,
            &quot;last 1 firefox version&quot;,
            &quot;last 1 safari version&quot;
          ]
        },
        &quot;devDependencies&quot;: {
          &quot;@babel/plugin-proposal-class-properties&quot;: &quot;^7.10.4&quot;,
          &quot;@reportportal/agent-js-jest&quot;: &quot;^5.0.1&quot;,
          &quot;jest-sonar-reporter&quot;: &quot;^2.0.0&quot;
        }
      }
  </code></pre>
  <blockquote>
  <p>My World file looks like this</p>
  </blockquote>
  <pre><code>import { setWorldConstructor,setDefaultTimeout } from 'cucumber'
  import chrome from 'selenium-webdriver/chrome'
  import  {Builder} from 'selenium-webdriver'
   
  export function  CustomerWorld({attach, parameters}) {
        this.attach = attach
        this.parameters = parameters
         this.driver =  new Builder()
        .forBrowser('chrome')
        .setChromeOptions(new chrome.Options().headless())
        .build()
        setDefaultTimeout(30000 * 1000);
      }
      
  setWorldConstructor(CustomerWorld);
  </code></pre>
  <blockquote>
  <p>And the test looks like</p>
  </blockquote>
  <pre><code>import {Given,When,Then } from 'cucumber'
  import {By} from 'selenium-webdriver'
  import expect from 'expect'
  
          let driver
           Given('I am currently loged out', async function () { 
              driver =  this.driver
              await driver.get('http://localhost:3000');
              const loginLink = await driver.findElement(By.id('loginLink'))
              expect(loginLink)
              loginLink.click()
              
           });
  </code></pre>
  <blockquote>
  <p>How do I fix this error?</p>
  </blockquote>