Unable to connect to postgres using deno.js

Viewed 378

Unable to connect to postgres in deno.js.

Here is the configuration:

const dbCreds = {
      applicationName: "appname",
      user: "user_sfhjwre",
      database: "d9iu8mve7nen",
      password: "68790f31eelkhlashdlkagsvADSDa52f9d8faed894c037ef6f9c9f09885603",
      hostname: "ec2-345-34-97-212.eu-east-1.xx.amazonaws.com",
      port: 5432,
    };
    export { dbCreds };

Usage:

import { Client } from "https://deno.land/x/postgres/mod.ts";        
import { dbCreds } from "../config.ts";

const client = new Client(dbCreds);    
await client.connect();

Also tried:

config = "postgres://user@localhost:5432/test?application_name=my_custom_app";
const client = new Client(config);
await client.connect();

Same result:

Uncaught Error: Unknown auth message code 1397113172

Is there anything wrong with the syntax, I can connect to the same db using prisma.

1 Answers

I have the PostgreSQL server in a remote server and, each time my public IP changes, I need to change the pg_hba.conf in order to set my new public IP as authorized for remote access.

Hope this helps.

Best regards.

Related