Can I access a postgres database of an app from outside?
-
@doodlemania2 That's a shame, do you or anyone know when it will be possible or if it ever will be?
-
@devtron Depends on the app / client. For example, with mysql workbench , this is quite straight forward because it supports SSH tunneling . Please see https://forum.cloudron.io/topic/3237/remote-sql-support-on-a-per-app-basis/2 . Which client will you be using for postgresql ?
-
pgadmin seems to support this - https://fedingo.com/pgadmin-connect-via-ssh-tunnel/
In general, the good tools should support SSH tunnels, since databases are almost never straight up exposed to the internet. They are in a VPC/Private network and you SSH/VPN into a bastion host.
-
-
Hey @devtron .
I was curious about it too, so just tried the same using DBeaver.
I was able to successfully access Directus' Postgres database by:
- configuring SSH connection to the server that Cloudron is hosted on
- using:
- host = value gotten from the host server by using `docker inspect postgresql | grep IPAddress
- database = value gotten from Directus' 'terminal' (echo $CLOUDRON_POSTGRESQL_DATABASE)
- username = value gotten from Directus' 'terminal' (echo $CLOUDRON_POSTGRESQL_USERNAME)
- password = value gotten from Directus' 'terminal' (echo $CLOUDRON_POSTGRESQL_PASSWORD)
-
@shrey Thanks, that motivated me to get started with a guide.
I wrote the mysql guide first - https://docs.cloudron.io/guides/connect-mysql/ . Working on the postgres one (but it's really very similar).
-
PostgreSQL guide is up as well - https://docs.cloudron.io/guides/connect-postgresql/
-
-
-
Hi @girish .
I do have some feedback regarding the currently suggested method, as described in these new guides.
After using this method for quite a few days, finding the internal ip address of the db containers has almost become the Achilles heel for any operation that uses this feature. That's because, the internal ip address keeps on changing, every now and then.
And so far, i haven't been able to identify a way to connect to the db by a static name/ip/uri.
Would appreciate if a solution for that is posted as well!
Thanks.
-
-
-
I have given these stable IPs now - https://git.cloudron.io/cloudron/box/-/commit/582994b9d646989b42e27dde1ae0c27bbb964834