Windows10上のHomesteadで、Laravel dusk環境を作る方法(Failed to connect to localhost対策含む)

This time, I have summarized how to create Laravel dusk environment with Homestead on Windows 10.

In addition, building a Homestead environment on Windows 10 is summarized in the following article.
How to build Laravel Homestead on Windows 10 Summary

OK.Let’s go.

It is assumed that the homestead environment and Laravel have been installed.

(1) Install laravel duskand initialize

■Laravel 5.8 Laravel Dusk (Official)

composer require --dev laravel/dusk
php artisan dusk:install

Preparation is complete only with the above two lines.

php artisan dusk

So, I should be able to do a browser test, but when I run it I get the following error:

Failed to connect to localhost port 9515: Connection refused

Apparently, in Homestead environment built on Windows 10, Chrome driver seems strange.

(参考)■Homestead上でlaravelのdusk使おうとしたらFailed to connect to localhost port 9515: Connection refusedって言われる(Japanese only)

I referred to the above site.

First, launch vagrant and enter virtual machine

vagrant up
vagrant ssh

Next, install chrome-driver

sudo apt install libnss3

sudo wget -q -O - | sudo apt-key add -
sudo sh -c 'echo "deb stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install google-chrome-stable

Now you can run dusk.

In addition, in using this method

vagrant destroy --force

It seems to be necessary to do it again when deleting a virtual machine and then vagrant up.


Posted by dog-ears