Cannot use ipv6 for DB_HOST value #5164

Closed
opened 2026-02-05 09:45:23 +03:00 by OVERLORD · 6 comments
Owner

Originally created by @rosalina-ha on GitHub (Feb 1, 2025).

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

Originally created by @rosalina-ha on GitHub (Feb 1, 2025). ### 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
OVERLORD added the 🐛 Bug label 2026-02-05 09:45:23 +03:00
Author
Owner

@enkrypt3d commented on GitHub (Mar 10, 2025):

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

@enkrypt3d commented on GitHub (Mar 10, 2025): Having the same issue. No matter what I do, laravel wont connect via ipv6. Did you find a solution?
Author
Owner

@ssddanbrown commented on GitHub (Mar 11, 2025):

@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:

13dae24cbe/app/Config/database.php (L44-L49)

This needs reworking in a considerate way.

@ssddanbrown commented on GitHub (Mar 11, 2025): @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: https://github.com/BookStackApp/BookStack/blob/13dae24cbe3f95ba6747f1ffe37bc3e1a4db4af9/app/Config/database.php#L44-L49 This needs reworking in a considerate way.
Author
Owner

@rosalina-ha commented on GitHub (Mar 11, 2025):

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)

@rosalina-ha commented on GitHub (Mar 11, 2025): > 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)
Author
Owner

@ssddanbrown commented on GitHub (Mar 15, 2025):

This has now been addressed within 4f5ad171ac, 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.

@ssddanbrown commented on GitHub (Mar 15, 2025): This has now been addressed within 4f5ad171ac239dacbf7dad4193366dfbacba5015, to be part of the next patch release. The square bracket format (with optional port) will be usable from that release: ```bash DB_HOST=[::1] DB_HOST=[::1]:3307 ``` Thanks @rosalina-ha for raising.
Author
Owner

@enkrypt3d commented on GitHub (Mar 17, 2025):

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?

@enkrypt3d commented on GitHub (Mar 17, 2025): > This has now been addressed within [4f5ad17](https://github.com/BookStackApp/BookStack/commit/4f5ad171ac239dacbf7dad4193366dfbacba5015), 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](https://github.com/rosalina-ha) for raising. So is DB_PORT= not used anymore?
Author
Owner

@ssddanbrown commented on GitHub (Mar 18, 2025):

@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.

@ssddanbrown commented on GitHub (Mar 18, 2025): @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 in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5164