How to connect a local Hasura instance with Postgres.app
I’ve just spent an unnecessary amount of time figuring out how to connect my locally running Hasura docker instance with the local postgres database started by Postgres.app. Therefore I’m sharing the solution here.
When adding a new data source in Hasura’s console:
- Select
Database URL
as Data Source - Enter the following inside the
Database URL
field:
postgres://USERNAME:@host.docker.internal:5432/USERNAME
- Replace
USERNAME
with your system user name. If you don’t know what it is, run the commandwhoami
in the terminal app.
The part I got stuck with was replacing localhost
as the database
url with host.docker.internal
, since that is what docker requires.
Luckily Hasura itself had this information buried in one of their
blog posts.
Maybe this saves somebody out there some time. ✌️