Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yevon opened this issue Mar 12, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@yevon
Copy link

yevon commented Mar 12, 2025

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,
  },
};
@yevon yevon added the bug Something isn't working label Mar 12, 2025
@yevon
Copy link
Author

yevon commented Mar 12, 2025

I realized that if I try to print pgtyped version it always shows 1.0.0, maybe this is the reason, but I have latest version installed I think: npx pgtyped --version

1.0.0

I tried reinstalling it multiple times, and forcing latest 2.4.2 version and it always returns version 1.0.0

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant