Password authentication failed error on running laravel migration
Asked Answered
H

1

3

I am trying to deploy my Laravel app on a DigitalOcean droplet. The droplet is setup with nginx, php7, and postgres, I follow up the tuts from DigitalOcean on how to set them up. Then I try to follow this tutorial on how to deploy the Laravel app using the git hook and so on.

Now the app itself is up and running, I can access the pages and all. But I can't run php artisan migrate. I have been changing the database username, name, password on .env file, but I always get the exact same error:

[Illuminate\Database\QueryException]
SQLSTATE[08006] [7] FATAL:  password authentication failed for user "deploy"
FATAL:  password authentication failed for user "deploy" (SQL: select * from information_schema.tables where table_schema = apollo and table_name = migrations)


[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[08006] [7] FATAL:  password authentication failed for user "deploy"
FATAL:  password authentication failed for user "deploy"


[PDOException]
SQLSTATE[08006] [7] FATAL:  password authentication failed for user "deploy"
FATAL:  password authentication failed for user "deploy"

Here is my latest .env config for the database:

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_USERNAME=postgres
DB_DATABASE=postgres
DB_PASSWORD=[my password]
DB_SCHEMA=public

As you can see, what is so absurd is that even with the DB_USERNAME is set to postgres, the error will still say for user "deploy".

I have been googling around and the closest thing, or I thought so, is to update some configuration on /etc/postgresql/9.5/main/postgresql.conf, which is to make listen_addresses = '*'. I updated it, restarted postgres service, and still get the exact same error.

Anyone can help me to point out what did I miss?

Thanks.

Horvath answered 22/2, 2017 at 3:20 Comment(4)
Just a long shot here. not a solution. try to clear your configuration cache. php artisan config:cache.Gimcrack
@Gimcrack that works! But now it seems like I have to clear the cache every time I changed the config. Is there a better solution to this?Horvath
How often do you actually configurations in a specific environment. Anyway, you can do php artisan config:clear to avoid caching.Gimcrack
You are right, thanks mate!Horvath
I
8

This happens due to caching.

When you run, php artisan config:cache, it will cache the configuration files. Whenever things get change, you need to keep running it to update the cache files. But, it won't cache if you never run that command.

This is OK for production, since config don't change that often. But during staging or dev, you can just disable caching by clearing the cache and don't run the cache command

So, just run php artisan config:clear, and don't run the command previously to avoid caching

Infectious answered 22/2, 2017 at 3:55 Comment(1)
This gives me a better understanding about the artisan commandsHorvath

© 2022 - 2024 — McMap. All rights reserved.