Brian Burns
Brian Burns

Reputation: 22042

Connect to Hasura Postgres database on DigitalOcean droplet

I've set up Hasura on a DigitalOcean droplet using the instructions here - https://docs.hasura.io/1.0/graphql/manual/guides/deployment/digital-ocean-one-click.html -

How can I connect to the Postgres database? Preferably using something like DBeaver - with host, database, user, password.

I guess the Postgres is running inside a Docker container, but how do you expose it to the outside world?

Upvotes: 1

Views: 1218

Answers (1)

Shahidh
Shahidh

Reputation: 2692

The docker-compose.yaml used on the Digital Ocean Marketplace does not expose the Postgres database on the host machine.

You can find the file at /etc/hasura/docker-compose.yaml. If your database management tool supports running as a docker container, I recommend adding it's relevant configuration to the docker-compose.yaml and exposing that application to the ouside like how graphql-engine is exposed via Caddy (config in /etc/hasura/Caddyfile.

But if you'd like to connect to postgres from within the machine, add a port mapping to the docker-compose file:

  postgres:
    image: postgres:10.5
    restart: always
    volumes:
    - db_data:/var/lib/postgresql/data
    ports:
    - "127.0.0.1:5432:5432"

Now, Postgres will be available at postgres://postgres:@127.0.0.1:5432/postgres

Do set a password if you're exposing it on the host machine.

Upvotes: 2

Related Questions