coollabsio/coolify · error · Exception

Could not get or generate proxy configuration

Error message

Could not get or generate proxy configuration

What it means

\Exception from GetProxyConfiguration when $proxy_configuration is still empty after both the stored configuration lookup and the fallback regeneration via generateDefaultProxyConfiguration($server, $custom_commands). The action even logs a 'Proxy configuration regenerated to defaults' warning before rebuilding, so this throw means regeneration itself produced an empty string - the server's proxy type/definition yielded no usable docker-compose content.

Source

Thrown at app/Actions/Proxy/GetProxyConfiguration.php:63

        // Generate default configuration as last resort
        if ($forceRegenerate || empty(trim($proxy_configuration ?? ''))) {
            $custom_commands = [];
            if (! empty(trim($proxy_configuration ?? ''))) {
                $custom_commands = extractCustomProxyCommands($server, $proxy_configuration);
            }

            Log::warning('Proxy configuration regenerated to defaults', [
                'server_id' => $server->id,
                'server_name' => $server->name,
                'reason' => $forceRegenerate ? 'force_regenerate' : 'config_not_found',
            ]);

            $proxy_configuration = str(generateDefaultProxyConfiguration($server, $custom_commands))->trim()->value();
        }

        if (empty($proxy_configuration)) {
            throw new \Exception('Could not get or generate proxy configuration');
        }

        ProxyDashboardCacheService::isTraefikDashboardAvailableFromConfiguration($server, $proxy_configuration);

        return $proxy_configuration;
    }

    /**
     * Check that the stored docker-compose YAML contains the expected service
     * for the server's current proxy type. Returns false if the config belongs
     * to a different proxy type (e.g. Traefik config on a CADDY server).
     */
    private function configMatchesProxyType(string $proxyType, string $configuration): bool
    {
        try {
            $yaml = Yaml::parse($configuration);
            $services = data_get($yaml, 'services', []);

View on GitHub (pinned to 70b9acc424)

Solutions

  1. Re-set the proxy type explicitly: Server -> Proxy -> select Traefik (or Caddy), save, then restart proxy to force regeneration.
  2. Inspect $server->proxy (type, force_stop) and proxyPath() contents on the server for a corrupted/empty docker-compose.
  3. Check the log for the preceding 'Proxy configuration regenerated to defaults' entry to confirm which branch (config_not_found vs force_regenerate) ran, and fix accordingly.

Example fix

// before
$proxy_configuration = str(generateDefaultProxyConfiguration($server, $custom_commands))->trim()->value();
...
if (empty($proxy_configuration)) {
    throw new \Exception('Could not get or generate proxy configuration');
}

// after (fail with actionable context)
if (empty($proxy_configuration)) {
    throw new \Exception('Could not get or generate proxy configuration for proxy type '.$server->proxyType().' on server '.$server->name);
}
Defensive patterns

Strategy: fallback

Validate before calling

$proxyType = $server->proxyType();
if (! in_array($proxyType, [\App\Enums\ProxyTypes::TRAEFIK->value, \App\Enums\ProxyTypes::CADDY->value], true)) {
    // set a supported proxy type before requesting configuration
    return;
}

Type guard

function hasSupportedProxyType(\App\Models\Server $server): bool
{
    return in_array($server->proxyType(), ['TRAEFIK', 'CADDY'], true);
}

Try / catch

try {
    $config = GetProxyConfiguration::run($server, forceRegenerate: true);
} catch (\Exception $e) {
    if ($e->getMessage() === 'Could not get or generate proxy configuration') {
        // reset proxy type to TRAEFIK, save, regenerate
    } else {
        throw $e;
    }
}

Prevention

When it happens

Trigger: Server proxy_type set to something with no template (CUSTOM/NONE or a corrupted value); generateDefaultProxyConfiguration returning empty because the resolved proxy type has no generator; empty config file on disk plus a regeneration path that short-circuits (e.g. unknown proxy type string after an upgrade or manual DB edit).

Common situations: Manually edited server.proxy JSON in the database leaving an unrecognized type; version upgrade introducing/renaming proxy types while stored config lags; disk full or permission issue making the stored file read as empty; swarm/local mismatches after switching server modes.

Related errors


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