hasura / hasura/graphql-engine

Hasura fails to connect to Postgres over IPv6 in Docker

Open
#8,189 3 comments 3 reactions 0 assignees View on GitHub
k/bug
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Version Information

Server Version:
latest Docker image

### Environment

K3d on a GNU/Linux laptop.

### What is the expected behaviour?

Hasura connects to a PostgreSQL container running on localhost.

### What is the current behaviour?

Hasura fails to connect to the db with the exact same error message as https://github.com/hasura/graphql-engine/issues/4069 . However, the hostname for the db is "localhost" instead of "docker.host.internal".

### How to reproduce the issue?

Set the PostgreSQL connection string environment variable to a database on localhost and start the Docker container. It will fail to connect. Then replace "localhost" with "127.0.0.1" in the connection string and restart Hasura. It will connect.

### Any possible solutions?

It's possible a nonstandard network configuration such as hardcoding IPv4 / AF_INET is in place in Hasura or a dependency. It's also possible a firewall or network configuration in the container itself is failing. I don't think it's a string parser choking on colons in an IPv6 address because the error message represents it as [::1]:$PORTNUM.

Most likely I think the Docker container was just not tested properly in an environment with native IPv6 subnets available. Please consider improving your integration tests.

### If the bug is confirmed, would you be willing to submit a PR?

Not at this time. I've only been using Hasura very briefly.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with Hasura in Docker using a PostgreSQL connection string with localhost, then compare it with 127.0.0.1 and the behavior described in issue 4069. Trace the connection path and inspect existing integration tests for localhost and IPv6 coverage. Done means localhost connects successfully in the reported Docker and IPv6 environment, with a regression test covering the case.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, postgresql
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.