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

PepsiIsBetter's avatar

run Dusk on Ubuntu20+VScode+DevContainer (Failed to connect to localhost port 9515 )

Hi,

I develop a local laravel project on Ubuntu20+VScode+DevContainer, by the official install instruction

After I followed the document to install Dusk, and then it run failed, but there is no article completely solve my problem.

The error messages are "Failed to connect to localhost port 9515: Connection refused" or something else which I don't remember...lol, because I have tried too many things.

After combined many solutions, the dusk run successfully on my computer.

so I post my solution here(all necessary settings) to help anyone who use the same environment.

.env

APP_ENV=local
APP_DEBUG=true
APP_URL=http://myproject.test
DUSK_DRIVER_URL=http://selenium:4444

devcontainer.json

"service": "myproject.test",

docker-compose.yml

services:
    myproject.test:
        depends_on:
            - selenium
    selenium:
        image: 'selenium/standalone-chrome'
        volumes:
            - '/dev/shm:/dev/shm'
        networks:
            - sail

If even you used php artisan dusk:install and php artisan dusk:chrome-driver and received the ChromeDriver binaries successfully installed message, but still had the connection refused error or other chrome related error, then you may add the script into your Dockerfile

    RUN curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
    && dpkg -i google-chrome-stable_current_amd64.deb; apt-get install -y -f \
    && rm -f google-chrome-stable_current_amd64.deb

If you have Telescope installed and have Class env does not exist ploblem. replace the line in the App\Providers\TelescopeServiceProvider.php

        Telescope::filter(function (IncomingEntry $entry) use ($disableFilter) {
            if ($this->app->environment('local')) { // change this line
                return true;
            }
            //
        });

to this

        $disableFilter = $this->app->environment(['local', 'testing']);
        Telescope::filter(function (IncomingEntry $entry) use ($disableFilter) {
            if ($disableFilter) {
                return true;
            }
            //
        });
0 likes
2 replies
PepsiIsBetter's avatar

@neilstee yes, I used php artisan dusk:chrome-driver when there was a chrome related error. But actually when I run php artisan dusk:install, it installed chrome-driver for me already, because it gave me ChromeDriver binaries successfully installed message.

There were different errors when I tried to use those solutions which I found online, but I don't remember details very clearly, sorry. (there is no errors since I using these settings, so I want to share them in case someone needs it)

If anyone face the situation like: even used php artisan dusk:install and php artisan dusk:chrome-driver and received the ChromeDriver binaries successfully installed message, but still had the connection refused error, then maybe they can try to add the RUN script in their Dockerfile to install chrome.

Please or to participate in this conversation.