title: Laravel Dusk - Failed to connect to localhost port 9515: Connection refused
body: <p>I want to create a test which I will use from Controller so I write:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers\Modules;
  namespace App\Http\Controllers;
  use Illuminate\Http\Request;
  use App\Http\Controllers\Controller;
  use Laravel\Dusk\ElementResolver;
  use Exception;
  
  use Facebook\WebDriver\Chrome\ChromeOptions;
  use Facebook\WebDriver\Remote\DesiredCapabilities;
  use Facebook\WebDriver\Remote\RemoteWebDriver;
  use Laravel\Dusk\Browser;
  use Laravel\Dusk\Chrome\ChromeProcess;
  
  class TestController extends Controller {
  
  
  
    public function test() {
  
      $process = (new ChromeProcess)-&gt;toProcess();
      if ($process-&gt;isStarted()) {
        $process-&gt;stop();
      }
      $process-&gt;start();
  
      $options      = (new ChromeOptions)-&gt;addArguments(['--disable-gpu', '--headless', '--no-sandbox']);
      $capabilities = DesiredCapabilities::chrome()
        -&gt;setCapability(ChromeOptions::CAPABILITY, $options);
  
            $driver = retry(1, function () use ($capabilities) {
        return RemoteWebDriver::create('http://localhost:9515', $capabilities, 60000, 60000);
      }, 50);
  
      $browser = new Browser($driver, new ElementResolver($driver, ''));
      $browser-&gt;resize(1920, 1080);
      $browser-&gt;visit('https://example.com/login')-&gt;click('#.btn &gt; form &gt; div.auth-form-body.mt-3 &gt; input.btn.btn-primary.btn-block');
      $browser-&gt;driver-&gt;takeScreenshot(base_path('tests/Browser/screenshots/logged.png'));
  
    }
  
  
  }
  </code></pre>
  
  <p>When I run this script using localhost:8000/test I got this message:</p>
  
  <blockquote>
    <p>Facebook \ WebDriver \ Exception \ WebDriverCurlException Curl error
    thrown for http POST to /session with params:
    {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"","args":["--disable-gpu","--headless","--no-sandbox"]}}}
    Failed to connect to localhost port 9515: Connection refused</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/KmdBp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KmdBp.png" alt="enter image description here"></a></p>
  
  <p>How I can solve this problem?</p>
  
  <p>Current I use WAMP server on Win10 for local testing but then I will move the code on Linux Ubuntu 18.</p>