Fix SERVICE_FQDN / COOLIFY_URL Magic Variables Empty on Coolify
Error: SERVICE_FQDN is empty / COOLIFY_URL is wrong or blank inside the container
Coolify's magic environment variables (SERVICE_FQDN_*, COOLIFY_URL) come out empty or stale inside the container instead of resolving to your app's real domain.
Coolify's magic variables (SERVICE_FQDN_*, COOLIFY_URL) are generated at deploy time from the service name plus its domain configuration, not read from a static value. Three things commonly break that generation: a dash in the service name gets mis-split when Coolify derives the variable name from it; the generic, non-port-suffixed form of a magic variable doesn't regenerate automatically after you change the app's domain later, so it keeps serving the old value; and Compose-from-Git resources only support these magic variables from Coolify v4.0.0-beta.411 onwards, so they're silently unavailable on older versions.
The fix
Confirm the Coolify version is v4.0.0-beta.411 or newer if you're deploying Compose from Git — magic variables aren't supported there on older releases.
Avoid dashes in service names that magic variables reference; use underscores instead, since dashes get mis-split when Coolify derives the variable name.
After changing a domain, switch to the port-specific variant (SERVICE_FQDN_<service>_<port>) instead of the generic one — the generic form doesn't regenerate on its own.
Fully redeploy the app (not just restart it) to force the magic variables to regenerate.
Verify it worked
Inside the running container, the variable matches the app's actual assigned domain rather than being empty or stale.
docker exec -it <container-name> env | grep SERVICE_FQDNRelated Coolify errors
- www.domain.com cert error but apex works
- Build-time error: process.env.NEXT_PUBLIC_* / VITE_* / API URL is undefined during build — values set in Coolify are empty in the built bundle (e.g. ReferenceError or fetch to "undefined")
- WebSocket connection to 'wss://<your-domain>:6001/app/...' failed (UI shows "WARNING: Cannot connect to real-time service")
- Coolify auto deploy not working / GitHub webhook shows no deliveries after a push
Sources
- github.com/coollabsio/coolify/issues/2470
- github.com/coollabsio/coolify/issues/6791
- github.com/coollabsio/coolify/issues/8912
- github.com/coollabsio/coolify/issues/6303