Exploring the depths of render.com

Accessing your render database with Node and pg.pool

postgres node.js mern

Does this look familiar?

Error: getaddrinfo ENOTFOUND

This error appears because you’re trying to connect to your render.com postgres instance but the client can’t locate the DB host.

I got this while using node-postgres’ pg.pool. I found pg.pool’s configuration to be tricky and took me a few tries to make it work. So here’s the configuration that worked for me to connect to my render.com postgres instance:

const pool = new Pool({
   host: "dpg-thisxisxmyxhost-a.oregon-postgres.render.com",
   ssl: true,
   port: 5432
   user: "mydb_avgf_user",
   database: "mydb_avgf",
   password: "aCOOLpassword"

The trick is that you have to leave the hostname completely free of the schema name and ssl specifics and give all of that to your configuration to let pg.pool manage it all for you.