Unable to connect to a running Laravel Sail Docker project with TablePlus (role does not exist)

Viewed 2479

I created a new Laravel project and installed Sail with composer require laravel/sail --dev followed by php artisan sail:install and sail up to get the project up and running in Docker.

By doing these actions my .env file changed from

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_docker
DB_USERNAME=root
DB_PASSWORD=

to

DB_CONNECTION=pgsql
DB_HOST=pgsql
DB_PORT=5432
DB_DATABASE=laravel_docker
DB_USERNAME=sail
DB_PASSWORD=password

And now I got two running Docker containers:

laravel-docker_laravel.test_1
laravel-docker_pgsql_1

I'm able to run the basic user migration with sail artisan migrate.

Next up I want to connect Tableplus (or Postico) with my Postgresql database running in Docker. Therefore I filled in the following information:

Tableplus screenshot

When trying to connect I got ERROR FATAL: role "sail" does not exist.

Can someone help me out?

Edit 1: Adding a screenshot from some terminal commands. I can connect to the database in the docker container, see a list of the tables and get a table with all the rows from the users table (inserted with a seeder using Laravel Sail)

CLI screenshot

Edit 2: docker-compose ps

docker-compose up screenshot

2 Answers

Thanks to this post I found a working solution.

Changing to a different port in the docker-compose.yml file fixed the issue.

Before:

pgsql:
    image: 'postgres:13'
    ports:
        - '${FORWARD_DB_PORT:-5432}:5432'

After:

pgsql:
    image: 'postgres:13'
    ports:
        - '${FORWARD_DB_PORT:-5632}:5432'

After changing the port number to 5632 in TablePlus I'm able to connect to the database.

I have the same problem "role "sail" does not exist". In this case we need to use command ./vendor/bin/sail down -v to delete the existing Docker volume data. After that you can do ./vendor/bin/sail up command.

Related