Skip to content

Unable to connect to posgresql 16.1 with scram-sha-256 password authentication #604

Open
@yevon

Description

@yevon

Describe the bug
I'm migrating a backend node express project for using TypeScript and pgtyped, but right now I'm unable to make it to work with my postgresql 16.1 database. The project and env vars work without problems locally. I can manually connect to the database without issues in dbeaver. Pgtyped is reading the env vars properly, so the only thing I found so far could be to the compatibility with scarm-sha-256 authentication? I read that this was supported already. The error received is just: Connection failed: password authentication failed for user "postgres"

If I look at the logs in the database,I can see the following, so it is already allowing connections from all hosts but with scram-sha-256 only:

"error_severity":"FATAL","sql_state_code":"28P01","message":"password authentication failed for user \"postgres\"","detail":"Connection matched file \"/var/lib/postgresql/data/pgdata/pg_hba.conf\" line 25: \"host all all all scram-sha-256\""

This is my current pgtyped.config.cjs

// pgtyped.config.cjs
require("dotenv").config({ path: ".env.local" });

module.exports = {
  transforms: [
    {
      mode: "sql",
      include: "**/*.sql",
      emitTemplate: "{{dir}}/{{name}}.queries.ts",
    },
  ],
  srcDir: "./src/trpc/queries/",
  camelCaseColumnNames: true,
  failOnError: true,
  db: {
    dbName: process.env.POSTGRES_DB,
    user: process.env.POSTGRES_USER,
    password: process.env.POSTGRES_PASSWORD,
    host: process.env.POSTGRES_HOST,
    port: Number(process.env.POSTGRES_PORT),
    ssl: false,
  },
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions