Postgres Connection Failure pga_hba.co... [Jul 27]

:raising_hand_man: jeanbonbeur asked

Hi! I just started the application by connecting it to a specific url with docker-compose (Ubuntu 22.04 - I indicate my url in the file /nocodb/docker-compose/traefik/.env and execute $cd nocodb/docker-compose/pg/ and $docker-compose up -d --build).

Then I chose to create a project with an existing Postgres database. After filling the fields the database connection test returns me: “Connection failed: connect ECONNREFUSED 127.0.0.1:5432”.

I am using Postgres v.14 / I can access my database with Pgadmin / I opened access to all IPs in the pg_hba.conf file (host all all 0.0.0.0/0 md5) and in the postgresql.conf file (listen_addresses = ‘*’) + service restart

I tried this solution: Postgres Connection Failure : pga_hba.conf entry for host .. , SSL off · nocodb/nocodb · Discussion #323 · GitHub but unsuccessful

I modify the file /nocodb/docker-compose/pg/docker-compose.yml with:

root_db: environment:

POSTGRES_PASSWORD: mypassword

POSTGRES_USER: myuser

POSTGRES_DB: mydb

nocodb: environment:

NC_DB: “pg://localhost:5432?u=myuser&p=mypassword&db=mydb”

Then restart a build + reload browser = Cannot GET /dashboard/

And If I set: NC_DB: “pg://root_db:5432?u=postgres&p=password&d=root_db”, It retrun with : “Connection failed: connect ECONNREFUSED 127.0.0.1:5432” and the browser console returns : demo-error

I m a newbie… I certainly missed something :confused: thks for helping!

:man_bald: dstala replied

<@996487497439781014>

If you are mac/linux- you can try host.docker.internal instead of localhost/127.0.0.1

:man_technologist: pranavxc replied

Or alternately you can specify network as host in docker compose — Compose file version 3 reference | Docker Docs

this way all ports will be available within docker container

:man_technologist: pranavxc replied

```yml

version: ‘2.1’

services:

nocodb:

image: nocodb/nocodb:latest

network_mode: “host”

restart: always

volumes:

- nc_data:/usr/app/data

environment:

NC_DB: “pg://localhost:5432?u=myuser&p=mypassword&db=mydb”

```

:raising_hand_man: jeanbonbeur replied

Perfect, thank you for your answers.

I fill in the file /nocodb/docker-compose/pg/docker-compose.yml the following values:

nocodb:

depends_on:

root_db:

condition: service_healthy

image: nocodb/nocodb:latest

network_mode: “host”

ports:

- “8080:8080”

restart: always

volumes:

- nc_data:/usr/app/data

environment:

NC_DB: “pg://localhost:5432?u=myuser&p=mypassword&d=mydb”

I run the following cmd: cd nocodb/docker-compose/pg/docker-compose.yml; docker-compose up -d --build

I reload my access page to the application. I connect to an existing database and I test the connection = success

Thanks a lot for your help !

Autogenerated from discord


Join NocoDB’s community

DiscordTwitterRedditDocs