1

My postgres pool is not connecting to the client and i'm almost sure that i passed the right properties to it.

That's the pool instance:


const { Pool } = require('pg')

module.exports = new Pool({
    host: 'localhost',
    port: 5432,
    user: 'laura',
    password: 123,
    database: 'launchstore'
})

And i created the postgres service with docker-compose:

version: '3.3'

services:
  postgres:
    container_name: postgres
    image: postgres
    environment:
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_DB: ${POSTGRES_DATABASE}
    ports:
      - "5432:5432"
    restart: unless-stopped

My env file:

POSTGRES_DATABASE=launchstore
POSTGRES_PASSWORD=123
POSTGRES_USER=laura

When i enter the page, it keeps loading and that's the result why i try to log the pool instance:

Pool {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  options: {
    Client: [Function: Client] { Query: [Function: Query] },
    host: 'localhost',
    port: 5432,
    user: 'laura',
    password: 123,
    database: 'postgres',
    max: 10,
    idleTimeoutMillis: 10000
  },
  log: [Function (anonymous)],
  Client: [Function: Client] { Query: [Function: Query] },
  Promise: [Function: Promise],
  _clients: [],
  _idle: [],
  _pendingQueue: [],
  _endCallback: undefined,
  ending: false,
  ended: false,
  [Symbol(kCapture)]: false
}

If i'm passing the right properties and my container is running, why my client can't connect to the pool?

1 Answer 1

1

The PG dependency wasn't installed correctly and that's why the pool wasn't working too. So it wasn't related to any configuration error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.