coollabsio / coolify

An open-source & self-hostable Heroku / Netlify / Vercel alternative.
https://coolify.io
Apache License 2.0
35.03k stars 1.93k forks source link

[Bug]: postgres database is unreachable locally #1837

Closed treboryx closed 1 month ago

treboryx commented 8 months ago

Description

A new postgres database is unreachable on the local network and you must do the following manually:

docker network connect <network name> <docker name>

This is potentially an issue with other containers too?

Minimal Reproduction (if possible, example repository)

Just create a new database and try to connect to it from your application

Exception or Error

No response

Version

v4.0.0-beta.236

andrasbacsai commented 8 months ago

What do you mean by "local network"?

If you create a database, for example, in the default Docker network called coolify, only applications in the same network could reach that database.

If you make the database public, it can be reached from anywhere.

treboryx commented 8 months ago

What do you mean by "local network"?

If you create a database, for example, in the default Docker network called coolify, only applications in the same network could reach that database.

If you make the database public, it can be reached from anywhere.

The problem is, when you create a new postgres database, the container of said database isn't connected to the coolify network. You have to manually do it then you'll be able to connect.

This was originally reported on Discord in the following thread. I suggest scrolling at the bottom (to avoid some irrelevant messages) where another user reported the same and the above solution worked for him as well.

https://discord.com/channels/459365938081431553/1207818952215101531/1216510826152853534

ytsdv commented 8 months ago

Same issue here with the pocketbase service, selecting a network in the new resource wizard doesn't automatically add pocketbase to it. Only solution seems to be the workaround from the discord thread.

treboryx commented 8 months ago

any update? it's becoming a hassle to deploy a new app.

hserranome commented 7 months ago

Same here. No way to connect to a database from another resource other than making it publicly available.

andrasbacsai commented 7 months ago

This is already solved. Let me know if it still does not work.

baatten commented 7 months ago

I ran into this problem. I can't connect to the db unless I use public address. I don't know how to solve this. I tried to use the simplest form of coolify I could. tried to delete both the web app (node) and the Postgres db but I can't connect locally. How can I solve this?

andrasbacsai commented 7 months ago

I will check it again. As I tested, it was working.

baatten commented 7 months ago

I ran into this problem. I can't connect to the db unless I use public address. I don't know how to solve this. I tried to use the simplest form of coolify I could. tried to delete both the web app (node) and the Postgres db but I can't connect locally. How can I solve this?

Our issues were due to a limitation of using nixpack. as told by @andrasbacsai nixpack is not supporting containerisation. We will start to use docker build instead. Thanks again for directions Andras :-)

herkulano commented 5 months ago

Same problem with nixpack running commands at build time that target the database, e.g. pnpm drizzle-kit migrate. I can only access the db with the public address.

stefnba commented 5 months ago

I have the same issue but not with posgres but with a FastAPI docker compose application. The postgres was automatically added to network "coolify" but not the FastAPI app.

After manually running docker network connect coolify app-qgsk8so-081040975032, it now works.

jhonmolano09 commented 1 month ago

I have the same issue but not with posgres but with a FastAPI docker compose application. The postgres was automatically added to network "coolify" but not the FastAPI app.

After manually running docker network connect coolify app-qgsk8so-081040975032, it now works.

Same problem here, when deploying Docker compose apps

EDIT: Inside an application advanced options, there is "Connect To Predefined Network" option, enabling it solves that issue.

peaklabs-dev commented 1 month ago

I am closing this in favor of this improvement: https://github.com/coollabsio/coolify/issues/2495. We will add a UI in a future release where you can select as many networks as you want after creating the DB or any container.