# Cannot access main postgres database with coolify

**URL:** <https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353>\
**Category:** Self-Host\
**Created:** [September 7, 2024, 7:36pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353 "2024-09-07T19:36:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![shady](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.nocodb.com/shady/32/528_2.png) [@shady](https://community.nocodb.com/u/shady)\
**Post date:** [September 7, 2024, 7:36pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/1 "2024-09-07T19:36:31Z")

</div>

I installed Noocdb on coolify. I added a postgres service to the project. Use the env variable NC\_DB with the value

```auto
pg://j4g44okskok04cks4kwogkkg:5432?u=postgres&p=<password>&d=postgres

```

but I am getting this error in logs post deployment while trying to run he service:

```auto
[Nest] 9 - 09/07/2024, 7:31:25 PM ERROR ;5;3m[ExceptionHandler] Error: getaddrinfo EAI_AGAIN j4g44okskok04cks4kwogkkg
Error: Error: getaddrinfo EAI_AGAIN j4g44okskok04cks4kwogkkg
    at NcConfig.create (/usr/src/app/docker/main.js:2:2228217)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async InstanceWrapper.useFactory [as metatype] (/usr/src/app/docker/main.js:2:1830025)
    at async Injector.instantiateClass (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:369:37)
    at async callback (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:65:34)
    at async Injector.resolveConstructorParams (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:144:24)
    at async Injector.loadInstance (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:70:13)
    at async Injector.loadProvider (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:97:9)
    at async /usr/src/app/node_modules/@nestjs/core/injector/instance-loader.js:56:13
    at async Promise.all (index 3)

```

Which means postgres client is unable to resolve the hostname of the pg service. To ensure this is not a coolify issue I created a simple nodejs application and added it to the same project. It was able to access pg service using the same hostname.

---

<div class="post-metadata">

**Author:** ![Navi](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@Navi](https://community.nocodb.com/u/Navi)\
**Post date:** [September 7, 2024, 7:42pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/2 "2024-09-07T19:42:40Z")

</div>

Please verify if your password has below character which might be interfering with env variable parsing (which is in URL format).

 ![image](https://canada1.discourse-cdn.com/flex011/uploads/nocodb/original/1X/68da8f5b7a424e673e93bece9215ac248ec1e552.png)

---

<div class="post-metadata">

**Author:** ![shady](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.nocodb.com/shady/32/528_2.png) [@shady](https://community.nocodb.com/u/shady)\
**Post date:** [September 7, 2024, 8:00pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/3 "2024-09-07T20:00:17Z")

</div>

It doesn’t. All numbers and letters. The error is caused by hostname resolution before even trying to connect. Also the hostname in the error message is correct which means the env variable was read properly.

---

<div class="post-metadata">

**Author:** ![shady](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.nocodb.com/shady/32/528_2.png) [@shady](https://community.nocodb.com/u/shady)\
**Post date:** [September 7, 2024, 10:20pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/5 "2024-09-07T22:20:08Z")

</div>

I used knex in my own nodejs application and it resolved the container name properly. I used the same knex connection json used in nocodb instance

---

<div class="post-metadata">

**Author:** ![Navi](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@Navi](https://community.nocodb.com/u/Navi)\
**Post date:** [September 8, 2024, 6:34am UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/6 "2024-09-08T06:34:34Z")

</div>

Glad this was figured out. If you could also mention what was the extra key you used in [NC\_DB\_JSON](https://docs.nocodb.com/getting-started/self-hosted/environment-variables/) that would be helpful to others in the community.

---

<div class="post-metadata">

**Author:** ![shady](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.nocodb.com/shady/32/528_2.png) [@shady](https://community.nocodb.com/u/shady)\
**Post date:** [September 8, 2024, 7:06am UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/7 "2024-09-08T07:06:41Z")

</div>

I only figured out that knex is able to resolve the db container hostname inside _my_ application, hence theoretically everything should work accordingly in nocodb. But it still doesn’t work in nocodb. I used the same knex json in NC\_DB\_JSON and I tried both methods: a connection object and a connection string url for the `connection` key. Both methods worked inside my application, and didn’t work inside nocodb

---

<div class="post-metadata">

**Author:** ![pranavxc](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@pranavxc](https://community.nocodb.com/u/pranavxc)\
**Post date:** [September 9, 2024, 5:39am UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/8 "2024-09-09T05:39:35Z")

</div>

> I only figured out that knex is able to resolve the db container hostname inside _my_ application

Can you give more details on this, Is your application running as a container ? If not then it looks like the host name not avail inside the nocodb container.

If you are using docker compose then can you share the compose file ? Although from where the `j4g44okskok04cks4kwogkkg` hostname is derived? Is it a container id or did you added it in `hosts` file ?

---

<div class="post-metadata">

**Author:** ![shady](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.nocodb.com/shady/32/528_2.png) [@shady](https://community.nocodb.com/u/shady)\
**Post date:** [September 9, 2024, 6:25am UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/9 "2024-09-09T06:25:08Z")

</div>

Coolify uses nixpacks to run my application inside a container. This container is part of the same project that also has pg container and nocodb container. They are connected together with a docker network also managed by coolify.

j4g44okskok04cks4kwogkkg is the pg container name which should be resolved by the docker network to point to the correct container. Inside my application this resolution happens and my application is able to connect to pg using knex.

---

<div class="post-metadata">

**Author:** ![pranavxc](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@pranavxc](https://community.nocodb.com/u/pranavxc)\
**Post date:** [September 9, 2024, 9:08am UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/10 "2024-09-09T09:08:18Z")

</div>

Is it possible to get inside nocodb docker container and check the host available or not ? Although confirm that both are under same network.

Following threads may help as well - [The getaddrinfo EAI\_AGAIN error again · Issue #15780 · nodejs/node · GitHub](https://github.com/nodejs/node/issues/15780) , [javascript - What's the cause of the error 'getaddrinfo EAI\_AGAIN'? - Stack Overflow](https://stackoverflow.com/questions/40182121/whats-the-cause-of-the-error-getaddrinfo-eai-again)

---

<div class="post-metadata">

**Author:** ![Navi](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@Navi](https://community.nocodb.com/u/Navi)\
**Post date:** [September 9, 2024, 10:52am UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/11 "2024-09-09T10:52:25Z")

</div>

After reading above it feels more issue with how coolify is setting up things for you (I 've not tried it so can not comment much)

However, if you have a VPS/Server : you should definitely try our new installation command - just a single one

`bash <(curl -sSL http://install.nocodb.com/noco.sh) <(mktemp)`

[Notes from our docs](https://docs.nocodb.com/getting-started/self-hosted/installation/auto-upstall)

> What is auto-upstall ?  
> Auto-upstall is the fastest way to install NocoDB with SSL, auto-upgrades with every release, and auto-renews your SSL — all within just 2 minutes!
> 
> How it works when we run it ? :
> 
> - 🐋 First it automatically installs all pre-requisites on your linux based server (docker, docker-compose)
> - 🚀 Then automatically installs
> - 🇳 NocoDB,
> - 🐘 PostgreSQL,
> - ⚡ Redis,
> - 🗄 Minio,
> - 🌐 Traefik gateway.
> 
> - 🔄 Also automatically upgrades NocoDB when new versions are available.
> - 🔒 And finally automatically sets up SSL that auto-renews!

---

<div class="post-metadata">

**Author:** ![shady](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.nocodb.com/shady/32/528_2.png) [@shady](https://community.nocodb.com/u/shady)\
**Post date:** [September 10, 2024, 6:05pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/12 "2024-09-10T18:05:39Z")

</div>

Thank you for your suggestion and time, but this does not solve the case of installing NocoDB on coolify which is what I am trying to achieve. I am sure installing NocoDB directly on the server will work but this is not what I’m trying to do. It needs to be installed on coolify.

---

<div class="post-metadata">

**Author:** ![shady](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.nocodb.com/shady/32/528_2.png) [@shady](https://community.nocodb.com/u/shady)\
**Post date:** [September 10, 2024, 6:47pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/13 "2024-09-10T18:47:05Z")

</div>

Coolify allows you to run commands inside the container. I am able to ping the container name from inside my app container but not nocodb container. I got the IP address of the PG container from my application. I am able to ping it from inside nocodb container. I used the IP address as the hostname in NC\_DB\_JSON but received the new exception:

```auto
[Nest] 8 - 09/10/2024, 6:43:53 PM ERROR ;5;3m[ExceptionHandler] KnexTimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
Error: KnexTimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
    at NcConfig.create (/usr/src/app/docker/main.js:2:2228217)
    at async InstanceWrapper.useFactory [as metatype] (/usr/src/app/docker/main.js:2:1830025)
    at async Injector.instantiateClass (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:369:37)
    at async callback (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:65:34)
    at async Injector.resolveConstructorParams (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:144:24)
    at async Injector.loadInstance (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:70:13)
    at async Injector.loadProvider (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:97:9)
    at async /usr/src/app/node_modules/@nestjs/core/injector/instance-loader.js:56:13
    at async Promise.all (index 3)
    at async InstanceLoader.createInstancesOfProviders (/usr/src/app/node_modules/@nestjs/core/injector/instance-loader.js:55:9)

```

---

<div class="post-metadata">

**Author:** ![pranavxc](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@pranavxc](https://community.nocodb.com/u/pranavxc)\
**Post date:** [September 11, 2024, 1:06pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/14 "2024-09-11T13:06:34Z")

</div>

Can you share the sample(with dummy value) of `NC_DB_JSON` value you are using.

---

<div class="post-metadata">

**Author:** ![shady](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.nocodb.com/shady/32/528_2.png) [@shady](https://community.nocodb.com/u/shady)\
**Post date:** [September 11, 2024, 1:59pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/15 "2024-09-11T13:59:38Z")

</div>

{“client”:“pg”,“connection”:{“host”:“172.18.0.7”,“port”:5432,“user”:“postgres”,“password”:“password”,“database”:“postgres”}}

---

<div class="post-metadata">

**Author:** ![Navi](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@Navi](https://community.nocodb.com/u/Navi)\
**Post date:** [September 11, 2024, 2:27pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/16 "2024-09-11T14:27:44Z")

</div>

Hey @shady, at this juncture - I would like you to urge to figure it out by running a bare minimal docker compose on a VPS with postgres to check how it works. And there are like 1000s of installations running like this. It will help you figure the missing parts with coolify. Its beyond us to support / figure what is going wrong specially at coolify.

---

<div class="post-metadata">

**Author:** ![shady](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.nocodb.com/shady/32/528_2.png) [@shady](https://community.nocodb.com/u/shady)\
**Post date:** [September 12, 2024, 1:35pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/17 "2024-09-12T13:35:22Z")

</div>

Got the response from coolify issue queue. Had to set “connect to predefined network” for this to work.

> **[How to use Docker Compose deployments with Coolify.](https://coolify.io/docs/knowledge-base/docker/compose/#connect-to-predefined-networks)**
>
> A guide on how to use Docker Compose deployments with Coolify.

---

<div class="post-metadata">

**Author:** ![Navi](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@Navi](https://community.nocodb.com/u/Navi)\
**Post date:** [September 12, 2024, 1:37pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/18 "2024-09-12T13:37:10Z")

</div>

That is so great to hear.

If you don’t mind - please add a sample of docker-compose or likes here or make a PR in our github.

This will be so useful to both nocodb and coolify community.

---

<div class="post-metadata">

**Author:** ![shady](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.nocodb.com/shady/32/528_2.png) [@shady](https://community.nocodb.com/u/shady)\
**Post date:** [September 12, 2024, 6:39pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/19 "2024-09-12T18:39:00Z")

</div>

I am using coolify application installation which pulls nocodb/nocodb docker image and deploys it. I do not make any changes to the docker-compose file. It’s just a setting in coolify that forces containers in docker-compose deployments to use the coolify network and not its own.

---

<div class="post-metadata">

**Author:** ![shady](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.nocodb.com/shady/32/528_2.png) [@shady](https://community.nocodb.com/u/shady)\
**Post date:** [September 13, 2024, 6:40pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/20 "2024-09-13T18:40:27Z")

</div>

I was able to reach PG container from NocoDB instance, but for some reason this deployment wont even read the env variables directly from coolify, I had to edit docker-compose in coolify under service stack and add those:

```yaml
services:
  nocodb:
    environment:
      - 'NC_REDIS_URL=${NC_REDIS_URL}'
      - 'NC_DB=${NC_DB}'

```

Now I have a working instance that’s connected to PG.

---

<div class="post-metadata">

**Author:** ![elgoko](https://avatars.discourse-cdn.com/v4/letter/e/5daacb/32.png) [@elgoko](https://community.nocodb.com/u/elgoko)\
**Post date:** [January 11, 2025, 2:23pm UTC](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353/21 "2025-01-11T14:23:07Z")

</div>

As a user, when I install Nocodb on coolify , it create a sql defaut database .

I tried like you from the new project to add 🙂

```
  - 'NC_REDIS_URL=${NC_REDIS_URL}'
  - 'NC_DB=${NC_DB}'

```

but when I try to access to my new session through the url :

I get a blackscreen and “no available server” !!!

I have double check my both PG and Redis variable and credential, and all good, but can’t make nocodb use prostgress instead of the default SQL

[Next page](https://community.nocodb.com/t/cannot-access-main-postgres-database-with-coolify/1353.md?page=2)
