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

MemoNick's avatar

Dusk: All routes fail with unknown command

Hi! I have a fresh install of Laravel 8.75 with Dusk 6.22 on Ubuntu 20.04. I have installed dusk correctly, using php artisan dusk:install. To run tests, I am simply calling php artisan dusk, but even trivial tests are failing with the error below. For example, if I call $browser->visit('/anypage'), I get the following output in the browser, so the test fails.

{ "value":
    { "error":"unknown command",
      "message":"unknown command: unknown command: anypage",
      "stacktrace":"#0 0x5561bf5e33e3 \u003Cunknown>\n#1 0x5561bf348468 \u003Cunknown>\n#2 0x5561bf3991de \u003Cunknown>\n#3 0x5561bf398f57 \u003Cunknown>\n#4 0x5561bf31f634 \u003Cunknown>\n#5 0x5561bf32044a \u003Cunknown>\n#6 0x5561bf60ff56 \u003Cunknown>\n#7 0x5561bf6272ad \u003Cunknown>\n#8 0x5561bf611dae \u003Cunknown>\n#9 0x5561bf627c34 \u003Cunknown>\n#10 0x5561bf605be2 \u003Cunknown>\n#11 0x5561bf31f206 \u003Cunknown>\n#12 0x7f5f2c10d0b3 \u003Cunknown>\n"}}

This is my driver() function:

protected function driver()
{
    $options = (new ChromeOptions)->addArguments(collect([
        '--window-size=1920,1080',
    ])->unless($this->hasHeadlessDisabled(), function ($items) {
        return $items->merge([
            '--disable-gpu',
            '--headless',
        ]);
    })->all());

    return RemoteWebDriver::create(
        $_ENV['DUSK_DRIVER_URL'] ?? 'http:// localhost:9515',
        DesiredCapabilities::chrome()->setCapability(
            ChromeOptions::CAPABILITY, $options
        )
    );
}

And in the .env file, I have set APP_URL=http:// localhost:9515 (ignore the space after http; as a newly-registered member, the forum doesn't let me post URLs). I have tried replacing localhost with 127.0.0.1 and even tried launching the chromedriver manually, to no avail.

I am running Google Chrome 99.0.4844.84 and Chromium 99.0.4844.84 snap with ChromeDriver 99.0.4844.51. I first faced the problem on an old installation of Laravel 5.4, which is why I attempted a fresh install.

Has anyone else faced the same problem? What do you suggest I do?

EDIT: I've tested with a few options. One option changes the output of php artisan dusk: the --headless option. With the --headless option, I get the unknown command error. Without the --headless option, the test doesn't even start, and I get the following error:

	Facebook\WebDriver\Exception\UnknownErrorException: unknown error: Chrome failed to start: exited abnormally.
	(unknown error: DevToolsActivePort file doesn't exist)
	(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
0 likes
7 replies
Sinnbeck's avatar

You have a space in the url

'http:// localhost:9515',
MemoNick's avatar

@Sinnbeck That's only because the forum doesn't let me add links to a post on my first day as a registered user

Sinnbeck's avatar

Does the error change if you try with the default set up from the docs?

return RemoteWebDriver::create(
        'http://localhost:9515', DesiredCapabilities::chrome()
    );
MemoNick's avatar

@Sinnbeck That gives me a different error (this time in the terminal, before the tests start):

Facebook\WebDriver\Exception\UnknownErrorException: unknown error: Chrome failed to start: exited abnormally.

(unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Adding any options fixes the error (I also tried --no-sandbox and --disable-dev-shm-usage), but it fails downstream with the unknown command in the original post. I wonder if it's a problem with the browser not launching correctly.

EDIT: I forgot to mention that the code in the original post is the default code generated by Laravel and Dusk on installation

MemoNick's avatar

I've tested with a few options. One option changes the output of php artisan dusk: the --headless option. With the --headless option, I get the unknown command error. Without the --headless option, the test doesn't even start, and I get the following error:

	Facebook\WebDriver\Exception\UnknownErrorException: unknown error: Chrome failed to start: exited abnormally.
	(unknown error: DevToolsActivePort file doesn't exist)
	(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
MemoNick's avatar

It seems like the browser itself has a problem running headless. When I run /snap/chromium/1945/usr/lib/chromium-browser/chrome --disable-gpu --headless, I get the following output, and then the browser seems to crash. I would greatly appreciate any help because none of the solutions I found have worked.

[0329/164819.608235:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
[0329/164819.630978:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.

If I remove --headless, the browser opens and works normally. In dusk, however, the tests still don't work.

Please or to participate in this conversation.