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

agahi's avatar
Level 1

Struggling with dusk, not found url

Hey everyone

UPDATE: After creating a custom 404 page I have found out that a "/session" is added to the url. Still no idea where this "/session" comes from.

I am trying to install and work with dusk on Centos 6.9 on a remote server.

I am following the documentation and so far I haven't managed and this is a summary of what I am through:

If I leave the file \dusk\tests\DuskTestCase.php like this:

    protected function driver()
    {
        return RemoteWebDriver::create(
            'http://localhost:9515', DesiredCapabilities::chrome()
        );
    }

And run php artisan dusk I will get the error:

There was 1 error:

1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY"}}

Failed to connect to localhost port 9515: Connection refused


If I change \dusk\tests\DuskTestCase.php to - I removed the port number -

    protected function driver()
    {
        return RemoteWebDriver::create(
            'http://localhost', DesiredCapabilities::chrome()
        );
    }

I'll get error 404 like this:

1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\WebDriverException: JSON decoding of remote response failed.
Error code: 4
The response: '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /session was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>'

If I try Google.com like this:

    protected function driver()
    {
        return RemoteWebDriver::create(
            'http://www.google.com/', DesiredCapabilities::chrome()
        );
    }

It actually goes to google but again it return that 404 screen of Google as follow:

'<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/session</code> was not found on this server.  <ins>That’s all we know.</ins>

Unfortunately neither of these give the url that they tried to achieve and failed.

What am am I doing wrong here?

0 likes
3 replies
adamfrancoSogeti's avatar

I am not much help as I am coming across the same problem. Hopefully someone can help us soon!

shez1983's avatar

whats your dusk test case..

you shouldnt be doing anything to the base classes.. revert the code, do a test dusk function test it out and if it fails post the code/error/screenshot here

i have been using dusk test for the past week and its been going fine for me..

thangnm's avatar

I had a same problem and figure it out (in my case): In .env file, the APP_URL I kept the default value http://localhost so in the test it will treat this as default location (which in my case turn into a Laragon default index).

I changed it to myapp.test, run php artisan config:cache to make the change in .env to take effect. Then it works.

1 like

Please or to participate in this conversation.