0

I've got Hasura running on a DigitalOcean droplet pointing to a managed Postgres instance on DigitalOcean - it works well.

But now I'm trying to make another Hasura droplet point to a test database in that Postgres instance.

I created the database okay, set the permissions following the instructions here, then tried to point the new Hasura at it, but can't get into the Hasura browser console at http://[ipaddr]/console - it says "502 Bad Gateway".

The error log includes this -

/etc/hasura# docker logs a5cff6c32cdf {"internal":"could not connect to server: Connection timed out\n\tIs the server running on host \"[dohost]\" ([ipaddr]) and accepting\n\tTCP/IP connections on port 25060?\n","path":"$","error":"connection error","code":"postgres-error"}

I can connect to the new test db okay though through DBeaver.

The /etc/hasura/docker-compose.yaml file looks like this, following the instructions here -

version: '3.6'
services:
  #postgres:
  #  image: postgres:10.5
  #  restart: always
  #  volumes:
  #  - db_data:/var/lib/postgresql/data
  graphql-engine:
    image: hasura/graphql-engine:v1.1.0
    #depends_on:
    #- "postgres"
    restart: always
    environment:
      # database url to connect
      HASURA_GRAPHQL_DATABASE_URL: postgresql://doadmin:<password>@<dourl>:25060/testdb?sslmode=require
      # enable the console served by server
      HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set "false" to disable console
      ## uncomment next line to set an admin secret key
      # HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
    command:
    - graphql-engine 
    - serve
  caddy:
    image: abiosoft/caddy:0.11.0
    depends_on:
    - "graphql-engine"
    restart: always
    ports:
    - "80:80"
    - "443:443"
    volumes:
    - ./Caddyfile:/etc/Caddyfile
    - caddy_certs:/root/.caddy
volumes:
  # db_data:
  caddy_certs:

Any idea why I'm getting a 502?

Brian Burns
  • 20,575
  • 8
  • 83
  • 77

1 Answers1

1

Found the problem - I needed to add the new Hasura instance as a Trusted Source to the Postgres instance.

Click on the database cluster, click on Edit Sources, click on Edit by Trusted Sources, then add the Hasura instance name, e.g. "hasura-graphql-ubuntu-s-1vcpu-1gb-nyc1-01".

Brian Burns
  • 20,575
  • 8
  • 83
  • 77