title: Got unknown error: net::ERR_CONNECTION_REFUSED with laravel dusk in docker
body: <p>I'm trying to implement browser testing with Laravel Dusk in docker environment.
  But when I  run command <code>php artisan dusk</code> to testing (in my php container) it display this error for all my tests case:</p>
  <pre><code>1) Tests\Browser\ExampleTest::testBasicExample
  Facebook\WebDriver\Exception\UnknownErrorException: unknown error: net::ERR_CONNECTION_REFUSED
    (Session info: headless chrome=96.0.4664.45)
  
  /var/www/vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:139
  /var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:372
  /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:585
  /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteExecuteMethod.php:27
  /var/www/vendor/php-webdriver/webdriver/lib/WebDriverNavigation.php:41
  /var/www/vendor/laravel/dusk/src/Browser.php:153
  /var/www/tests/Browser/ExampleTest.php:19
  /var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:69
  /var/www/tests/Browser/ExampleTest.php:21
  </code></pre>
  <p>Here is my configuration:</p>
  <p>I add <code>selenium</code> container to docker-compose file by this <a href="https://laravel.com/docs/8.x/sail#laravel-dusk" rel="nofollow noreferrer">introduction</a></p>
  <ul>
  <li><code>docker-compose.yaml</code></li>
  </ul>
  <pre class="lang-yaml prettyprint-override"><code>version: '3.7'
  
  networks:
      laravel:
  
  services:
      php:
          build:
              context: .
              dockerfile: dockers/php/Dockerfile
          container_name: php
          extra_hosts: 
              - &quot;host.docker.internal:host-gateway&quot;
          volumes:
              - ./:/var/www/
          ports:
              - &quot;9000:9000&quot;
          networks:
              - laravel
          depends_on:
              - selenium
      selenium:
          container_name: selenium
          image: 'selenium/standalone-chrome'
          volumes:
              - './selenium:/selenium'
          networks:
              - laravel
  </code></pre>
  <p>I have follow introduction in laravel documentation page <a href="https://laravel.com/docs/8.x/dusk#using-other-browsers" rel="nofollow noreferrer">here</a> to change <code>APP_URL</code> config to <code>http://selenium:4444/wd/hub</code></p>
  <ul>
  <li><code>DuskTestCase.php</code></li>
  </ul>
  <pre class="lang-php prettyprint-override"><code>    public static function prepare()
      {
          if (! static::runningInSail()) {
              static::startChromeDriver();
          }
      }
  
      protected function driver()
      {
          $options = (new ChromeOptions)-&gt;addArguments(collect([
              '--window-size=1920,1080',
          ])-&gt;unless($this-&gt;hasHeadlessDisabled(), function ($items) {
              return $items-&gt;merge([
                  '--disable-gpu',
                  '--headless'
              ]);
          })-&gt;all());
  
          return RemoteWebDriver::create(
              'http://selenium:4444/wd/hub', // change here
              DesiredCapabilities::chrome()-&gt;setCapability(
                  ChromeOptions::CAPABILITY, $options
              )
          );
      }
  </code></pre>
  <p>Then when I run testing in <code>php</code> container it show error above.</p>
  <h3>UPDATE</h3>
  <p>I've checked my <code>selenium</code> logs and it shows this error whenever I run command <code>php artisan dusk</code></p>
  <pre><code>Starting ChromeDriver 96.0.4664.45 (76e4c1bb2ab4671b8beba3444e61c0f17584b2fc-refs/branch-heads/4664@{#947}) on port 58188
  
  Only local connections are allowed.
  
  Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
  
  ChromeDriver was started successfully.
  
  [1639062447.255][SEVERE]: bind() failed: Cannot assign requested address (99)
  </code></pre>
  <p>I wonder if this erro come from my configuration or my implement steps. So, this is detail of steps I used to implement testing:</p>
  <pre><code>docker-compose build
  docker-compose up -d
  docker-compose exe php bash
  // php container
  php artisan config:clear
  php artisan dusk
  </code></pre>
  <p>Hope it help to figure out solution</p>