Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PersonalHomePage's avatar

password authentication failed for user "postgres"

This is my first time using postgres so I'm a little confused how to setup the connection here.

I installed postgres on Ubuntu from terminal with sudo apt install postgresql postgresql-contrib and I am able get into it using sudo -i -u postgres. I put this into my .env file

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=postgres
DB_USERNAME=postgres
DB_PASSWORD=postgres

and I'm getting the authentication error. I tried putting my root password in there as well, but that didn't change anything. What did I do wrong here?

complete error for reference :

php artisan migrate

   Illuminate\Database\QueryException 

  SQLSTATE[08006] [7] FATAL:  password authentication failed for user "postgres"
FATAL:  password authentication failed for user "postgres" (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
    667|         // If an exception occurs when attempting to run a query, we'll format the error
    668|         // message to include the bindings with SQL, which will make this exception a
    669|         // lot more helpful to the developer instead of just the database's errors.
    670|         catch (Exception $e) {
  > 671|             throw new QueryException(
    672|                 $query, $this->prepareBindings($bindings), $e
    673|             );
    674|         }
    675| 

      +34 vendor frames 
  35  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

0 likes
4 replies
PersonalHomePage's avatar

I saw that post too, and not using a password for it doesn't work either. Thanks anyway.

siangboon's avatar

what do you meant does not work either??

postgresql have a user "postgres" created with password "postgres" but still not able to connect?

Please or to participate in this conversation.