Laravel Brower Test (Dusk) error on MacOS (Docker): Failed to connect on localhost port 9515: connection refused
I just installed Laravel's Dusk to add browser tests. However, when I run a test, I get a Failed to connect on localhost port 9515: connection refused error.
I checked online and it seems like a lot of people are having the same issue. I came across few solutions e.g. this but it seems like they are all for Windows and Homestead whilst I am running my project on MacOS and Docker.
I did try to follow the solution but I found out sudo apt is not available for MacOS. I then installed Homebrew and tried to run the commands starting with brew instead of sudo apt but it responds saying no formula available for the name.
I would really appreciate it if you could recommend a solution or source I could look at. Thank you.
This I did try to follow the solution but I found out sudo apt is not available for MacOS clearly shows that you try to run your commands in wrong place. If you have docker then this is where your application lives, this is where you run your php artisan commands and etc.
Brew is for MacOS, your are not on MacOS, you are on docker which is linux and has apt get I'm sure you know how to log in into your docker machine and run php artisan commands in there. This is the right place.
On another note, do yourself a favour and install https://laravel.com/docs/master/valet I should mark a day when I discovered it in my calendar next to other important stuff 🤪