[Solved] Can't connect to database Laravel Sail

Laravel Safiul Tarek

Problem :

I'm trying to create a simple laravel project and I'm following a laracast to set up the project with Sail. The project is running fine and I was able to migrate with vendor/bin/sail artisan migrate. The next step in the laracast is to connect to the database with tableplus. But i can't get past this step. I get this error in tableplus:



php – Laravel sail can’t connect to database from host

Solution 1:

You should define

FORWARD_DB_PORT=3306

in your .env this will expose mysql on that port for development connections. I would recommend to not expose this port on production.


Solution 2:

I’ve Ubuntu 20.04 let's put it in. I’ve put in a Laravel undertaking with Laravel sail. All proper. After putting in laravel I run the migrations with “sail php artisan migrate”.

sail php artisan migrate

Thank you for reading the article. If you face any problems, please comment below.