ECONNREFUSED connect to Docker Selenium

config.yml

version: 2
jobs:
  javascript:
    docker:
      - image: cypress/base:12
        environment:
          TERM: xterm
      - image: selenium/hub:3.141.59-20200525
        name: selenium-hub
        environment:
          - GRID_MAX_SESSION=15
      - image: selenium/node-chrome:3.141.59-20200525
        environment:
          - HUB_HOST=selenium-hub
          - HUB_PORT=4444
          - NODE_PORT=5555
          - NODE_MAX_SESSION=5
          - NODE_MAX_INSTANCES=5
      - image: selenium/node-firefox:3.141.59-20200525
        environment:
          - HUB_HOST=selenium-hub
          - HUB_PORT=4444
          - NODE_PORT=5556
          - NODE_MAX_SESSION=5
          - NODE_MAX_INSTANCES=5
      - image: selenium/node-opera:3.141.59-20200525
        environment:
          - HUB_HOST=selenium-hub
          - HUB_PORT=4444
          - NODE_PORT=5557
          - NODE_MAX_SESSION=5
          - NODE_MAX_INSTANCES=5
    working_directory: ~/repo
    steps:
      - checkout
      - restore_cache:
          keys:
          # when lock file changes, use increasingly general patterns to restore cache
          - creatives-dynamic-{{ .Branch }}-{{ checksum "creatives-dynamic/yarn.lock" }}
          - creatives-dynamic-{{ .Branch }}-
          - creatives-dynamic-
      - run:
          name: Install creatives-dynamic dependencies and run tests.
          command: |
            cd creatives-dynamic
            ./run_tests.sh
      - save_cache:
          paths:
            - creatives-dynamic/node_modules
          key: creatives-dynamic-{{ .Branch }}-{{ checksum "creatives-dynamic/yarn.lock" }}

#parallelize?
workflows:
  version: 2
  all_builds:
    jobs:
      - javascript

Containers I am using: https://github.com/SeleniumHQ/docker-selenium
Containers end up talking to each other just fine, as the hub registers all three nodes.
However, the request to the address “http://localhost:4444/” in my tests fails with status ECONNREFUSED

Have you tried connecting to it via the name: parameter provided in the beginning of the config (selenium-hub) as opposed to localhost?

A quick test with netcat shows that it is available via the IP at that name

nc -z selenium-hub 4444

Quick edit for completeness to include the documentation about name:

https://circleci.com/docs/2.0/configuration-reference/#docker

The name the container is reachable by. By default, container services are accessible through localhost

1 Like

That was indeed my issue, for some reason specifying a name also closes localhost (that could be clearer in the docs). selenium-hub worked but I removed it so I could use good ol’ localhost.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.