coollabsio/coolify · error · InvalidArgumentException

Hostname must include a domain (e.g. example.com or app.exam

Error message

Hostname must include a domain (e.g. example.com or app.example.com).

What it means

Error "Hostname must include a domain (e.g. example.com or app.example.com)." thrown in coollabsio/coolify.

Source

Thrown at app/Support/DomainConnect/CloudflareDomainConnect.php:149

     * Uses a small multi-part public-suffix set for common cases (e.g. co.uk)
     * instead of shipping the full Mozilla Public Suffix List (~300KB).
     * Unknown multi-part TLDs fall back to last-two-labels; Cloudflare will
     * still match the user's zone when the guess is close enough.
     *
     * @return array{domain: string, host: string}
     */
    public static function splitHostname(string $hostname): array
    {
        $hostname = strtolower(trim($hostname));
        $hostname = preg_replace('#^https?://#', '', $hostname) ?? $hostname;
        $hostname = explode('/', $hostname)[0] ?? $hostname;
        $hostname = explode(':', $hostname)[0] ?? $hostname;
        $hostname = rtrim($hostname, '.');

        $labels = array_values(array_filter(explode('.', $hostname), fn (string $p) => $p !== ''));

        if (count($labels) < 2) {
            throw new InvalidArgumentException('Hostname must include a domain (e.g. example.com or app.example.com).');
        }

        $suffixLabelCount = self::publicSuffixLabelCount($labels);
        $registrableLabelCount = $suffixLabelCount + 1;

        if (count($labels) < $registrableLabelCount) {
            throw new InvalidArgumentException('Hostname must include a registrable domain.');
        }

        $domain = implode('.', array_slice($labels, -$registrableLabelCount));
        $hostLabels = array_slice($labels, 0, -$registrableLabelCount);
        $host = implode('.', $hostLabels);

        return ['domain' => $domain, 'host' => $host];
    }

    /**
     * How many trailing labels form the public suffix (effective TLD).

View on GitHub (pinned to 70b9acc424)

When it happens

Trigger: Thrown at app/Support/DomainConnect/CloudflareDomainConnect.php:149 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of coollabsio/coolify@70b9acc424 (2026-08-17). Data as JSON: /api/errors/e3b66b2a02c2c0b9. Report an issue: GitHub.