Skip to content

5.4.1: RuntimeException: Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6" #270

Description

@lkraav

Davis version

5.4.1

Installation method

Bare metal / manual

PHP version (bare metal only)

8.2.30

Database

MySQL

Reverse proxy

Apache

Authentication method

LDAP

Affected protocol(s)

  • CalDAV
  • CardDAV
  • WebDAV
  • Admin dashboard
  • API

Client(s) exhibiting the issue

All

Relevant environment variables

Needs `SYMFONY_TRUSTED_PROXIES=127.0.0.1`

Steps to reproduce

  1. disable PHP IPv6 (my Gentoo PHP build is systemwide -ipv6)
  2. launch Davis
  3. everything 500s

Expected behaviour

200

Actual behaviour

500

Logs


Additional context

This ended up easy pickings for Copilot

Reasoning

*The problem is clear: PHP was compiled without IPv6 support, but Symfony is trying to check IPv6 addresses. This is happening because SYMFONY_TRUSTED_PROXIES=REMOTE_ADDR is set, which causes Symfony to check if the remote address matches the trusted proxy list.

The fix could be:

  1. Change SYMFONY_TRUSTED_PROXIES to only use IPv4 addresses (not REMOTE_ADDR)
  2. Or ensure the REMOTE_ADDR being passed is always IPv4

Wait, let me think about this more. The REMOTE_ADDR special value in Symfony means "trust the remote IP as a proxy".

When Symfony validates this, it runs the IP through IpUtils::checkIp(), which attempts to determine if it's IPv6 by calling inet_pton(). Since IPv6 is disabled in PHP, inet_pton('::1') returns false and AF_INET6 isn't defined, causing the check to fail and throw an exception. The real solution is to either disable IPv6 checking when it's not available in PHP, or configure the trusted proxies to only accept IPv4 addresses. better approach would be to explicitly configure the trusted proxies with specific IPv4 addresses instead of relying on REMOTE_ADDR. Let me look for the framework configuration file to see how this is currently set up.*


Similar find in the wild: nextcloud/server#44475

This could potentially be a simple documentation patch, unless it makes sense to implement IPv6 detection in Davis?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions