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

naspy971's avatar

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

Hi,

I'm just trying a small project with postgres which I've never touched before.

I've set the default db as pgsql and configurres mon .env constants correctly.

Matter fact, I'm able to migrate tables successfully...

But when I try to register an account, I get this :

SQLSTATE[08006] [7] FATAL: password authentication failed for user "postgres" FATAL: password authentication failed for user "postgres" (SQL: select count(*) as aggregate from "users" where "email" = [email protected])

Here's my .env config :

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

When I tinker with DB::connection()->getPdo() :

 PDO {#2311
     inTransaction: false,
     attributes: {
       CASE: NATURAL,
       ERRMODE: EXCEPTION,
       PERSISTENT: false,
       DRIVER_NAME: "pgsql",
       SERVER_INFO: "PID: 8414; Client Encoding: UTF8; Is Superuser: on; Session Authorization: postgres; Date Style: ISO, MDY",
       ORACLE_NULLS: NATURAL,
       CLIENT_VERSION: "10.3",
       SERVER_VERSION: "10.3",
       STATEMENT_CLASS: [
         "PDOStatement",
       ],
       EMULATE_PREPARES: false,
       CONNECTION_STATUS: "Connection OK; waiting to send.",
       DEFAULT_FETCH_MODE: BOTH,
     },
   }

I really don't know what's going on here...

Thanks

0 likes
1 reply

Please or to participate in this conversation.