Skip to content

Cannot use ipv6 for DB_HOST value #5464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rosalina-ha opened this issue Feb 1, 2025 · 6 comments
Closed

Cannot use ipv6 for DB_HOST value #5464

rosalina-ha opened this issue Feb 1, 2025 · 6 comments
Labels
Milestone

Comments

@rosalina-ha
Copy link

Describe the Bug

When trying to set DB_HOST to use an IPv6, you can't run php artisan migrate

Steps to Reproduce

  1. Clone repository
  2. Configure .env DB_HOST to use an ipv6
  3. Execute php artisan migrate

Expected Behaviour

Work with an IPv6 for the DB_HOST value

Screenshots or Additional Context

Error message :

In Connection.php line 829:

  SQLSTATE[HY000] [2002] Failed to parse IPv6 address "[2a00:XXXX" (Connection: mysql, SQL: select table_name as `name`, (data_length + index_length) as `size`
  , table_comment as `comment`, engine as `engine`, table_collation as `collation` from information_schema.tables where table_schema = 'bookstack' and table_ty
  pe in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)


In Connector.php line 65:

  SQLSTATE[HY000] [2002] Failed to parse IPv6 address "[2a00:XXXX"

DB_HOST value use: [2a00:XXXX:XXXX:XXX::dba2]

Browser Details

No response

Exact BookStack Version

v24.12.1

@enkrypt3d
Copy link

Having the same issue. No matter what I do, laravel wont connect via ipv6. Did you find a solution?

@ssddanbrown
Copy link
Member

@enkrypt3d The underlying Laravel code might work fine, but it won't work right now for BookStack due to how we're splitting out the port from the host if set:

$mysql_host_exploded = explode(':', $mysql_host);
$mysql_port = env('DB_PORT', 3306);
if (count($mysql_host_exploded) > 1) {
$mysql_host = $mysql_host_exploded[0];
$mysql_port = intval($mysql_host_exploded[1]);
}

This needs reworking in a considerate way.

@rosalina-ha
Copy link
Author

Having the same issue. No matter what I do, laravel wont connect via ipv6. Did you find a solution?

I did not find solution since it's a bookstack problem as @ssddanbrown said but maybe you can use an hostname resolving to an ipv6 (did not try, I instead fell back to using ipv4)

@ssddanbrown ssddanbrown added this to the v25.02.1 milestone Mar 13, 2025
ssddanbrown added a commit that referenced this issue Mar 15, 2025

Verified

This commit was signed with the committer’s verified signature.
Zhenay Evgeny Seregin
Can be set via the square bracket format.
For #5464
@ssddanbrown
Copy link
Member

This has now been addressed within 4f5ad17, to be part of the next patch release.
The square bracket format (with optional port) will be usable from that release:

DB_HOST=[::1]
DB_HOST=[::1]:3307

Thanks @rosalina-ha for raising.

@enkrypt3d
Copy link

This has now been addressed within 4f5ad17, to be part of the next patch release. The square bracket format (with optional port) will be usable from that release:

DB_HOST=[::1]
DB_HOST=[::1]:3307
Thanks @rosalina-ha for raising.

So is DB_PORT= not used anymore?

@ssddanbrown
Copy link
Member

@enkrypt3d BookStack will use the port in the DB_HOST value otherwise, if not set/provided via the host, use DB_PORT otherwise fall back to 3306 as the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants