Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

samsalvatico's avatar

Connection refused after clear install using Sail

  • Dusk Version: v6.15.0
  • Sail Version: v1.7.0
  • Laravel Version: v8.43.0
  • PHP Version: 8.0.5
  • Docker Engine Version: 20.10.6
  • O.S.: macOs BigSur 11.3.1

Scenario:

After a clear install of Dusk on a new Laravel project that uses Sail a "Connection Refused" error is thrown

./vendor/bin/sail artisan dusk
PHPUnit 9.5.4 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 00:00.855, Memory: 20.00 MB

There was 1 error:

1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"args":["--window-size=1920,1080","--disable-gpu","--headless"]}}]},"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"args":["--window-size=1920,1080","--disable-gpu","--headless"]}}}

Failed to connect to localhost port 9515: Connection refused

/var/www/html/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:332
/var/www/html/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:135
/var/www/html/tests/DuskTestCase.php:46
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:218
/var/www/html/vendor/laravel/framework/src/Illuminate/Support/helpers.php:234
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:219
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:97
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:65
/var/www/html/tests/Browser/ExampleTest.php:21

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

I followed all instructions I found at Sail Docs and at Dusk Docs with no changes. My docker environment was completely cleared from old images and containers used by Laravel Sail Projects.

At first glance I tried editing anything on the project simply running dusk, so the APP_URL was the default one on .env file

APP_URL=http://selenium.test

But, after I read the docs at Dusk Docs the following sentence "Next, set the APP_URL environment variable in your application's .env file. This value should match the URL you use to access your application in a browser." I set it to the one I use on the browser

APP_URL=http://localhost

Steps To Reproduce:

  1. curl -s "https://laravel.build/selenium?with=selenium" | bash
  2. cd selenium && ./vendor/bin/sail up -d
  3. ./vendor/bin/sail composer require --dev laravel/dusk
  4. ./vendor/bin/sail artisan dusk:install
  5. ./vendor/bin/sail artisan dusk
  6. Try changing the APP_URL in .env and run the 5 point again

I cannot figure out why the problem occurs

0 likes
2 replies
thejci's avatar

I am currently having the same issue. Did anyone ever figure this out?

haszprus's avatar

Same here. Anyone? :) Thanks in advance.

(Cloned the project, set up everything, connection refused. No idea why.)

Please or to participate in this conversation.