Use chrome headless with circleci/ruby pre-built Docker image




After navigating and reading the multiple threads about the same issue and reading conflicting information, I am seeking guidance as to what is the way to go to run Rspec tests using Capybara and headless chrome with the pre-built Docker image from CircleCI. I was not able to make a successful connection (specs fail with Errno::ECONNREFUSED: Failed to open TCP connection to (Connection refused - connect(2) for "" port 4444)

Current setup:

  • ruby 2.3.6
  • rails 4.2.7
  • rspec 3.7.0
  • capybara 2.13
  • selenium-webdriver 3.8
  • CircleCI pre-build image: circleci/ruby-2.3.6-node-browsers


Capybara.register_driver :selenium do |app|
    browser: :remote,
    url: 'http://localhost:4444/wd/hub',
    desired_capabilities: :chrome

I am not sure what is wrong, could anyone point me out in the right direction?



Try swapping localhost out for


Thank you for your reply Ryan. I had already tried that but it didn’t work.

I got it working using the following:

Capybara.register_driver :headless_chrome do |app|
  capabilities =
    chromeOptions: { args: %w(headless disable-gpu) }
    browser: :chrome,
    desired_capabilities: capabilities

Is that how the selenium webdriver is supposed to be set up?

FWIW not having access to the pre-built Docker images’s Dockerfiles makes it harder to understand the setup.

Thank you,


Not sure on the Ruby specific aspects of it.


Thank you Ryan.

It would be more helpful if the actual Dockerfiles were accessible from Docker Hub (

I’ll have a look at the Dockerfile.


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