sea-orm icon indicating copy to clipboard operation
sea-orm copied to clipboard

Error connecting to database with ipv6 in connection string

Open Rudo2204 opened this issue 9 months ago • 3 comments

Description

I encountered an error connecting to my postgres database using connection string that uses raw ipv6 as hostname.

Steps to Reproduce

Using provided docker image, and run tests with: DATABASE_URL="postgres://root:root@[::1]" cargo test --all --features default,sqlx-postgres,runtime-async-std-native-tls In this case it's localhost, but I'm getting the same behavior for external hosts as well.

Expected Behavior

All tests pass.

Actual Behavior

Error encountered.

Error: Connection Error: error occurred while attempting to establish a TLS connection: invalid dns name
Caused by:
    0: error occurred while attempting to establish a TLS connection: invalid dns name
    1: error occurred while attempting to establish a TLS connection: invalid dns name
    2: invalid dns name

Reproduces How Often

Always reproducible.

Workarounds

Modify /etc/hosts to add a domain that points to the ipv6 address, and use that domain as replacement.

Versions

v1.1.10

Expected cause

url::Url::parse() code used doesn't seem to remove the bracket from host string, causing the error. This is similar to this issue: https://github.com/launchbadge/sqlx/pull/1818

Rudo2204 avatar Apr 23 '25 05:04 Rudo2204

Hi! Is the bug still open? I could try to solve it.

Thanks!

fulmicotone98 avatar Oct 17 '25 13:10 fulmicotone98

I don't know if it still exists, but I haven't seen any PRs about this issue.

Huliiiiii avatar Oct 17 '25 14:10 Huliiiiii

Currently the tests for async-std seem to be broken, I got this with tokio.

thread 'main' panicked at tests/common/setup/mod.rs:36:48:
called `Result::unwrap()` on an `Err` value: Conn(SqlxError(Io(Os { code: 97, kind: Uncategorized, message: "Address family not supported by protocol" })))

Huliiiiii avatar Oct 17 '25 16:10 Huliiiiii