symfony/routing · error · RouteNotFoundException
Target route " " for alias " " does not exist.
Error message
Target route "%s" for alias "%s" does not exist.
What it means
When dumping compiled routes, route aliases are resolved to their final target route by following the alias chain. This error means the chain ended at a route id that does not exist in the RouteCollection — a dangling alias (target removed or renamed).
Solutions
- Add or restore the target route the alias points to.
- Update the alias definition to point at the existing route id.
- Remove the stale alias from the collection/config.
- Check for alias chains with debug:router or by inspecting the collection for dangling ids.
Example fix
// before
$r->alias('new_name', 'removed_route');
// after
$r->alias('new_name', 'existing_route'); Defensive patterns
Strategy: validation
Validate before calling
foreach ($collection->all() as $name => $route) {
if ($route instanceof Alias && null === $collection->get($route->getId())) {
throw new LogicException("Alias $name points to missing route ".$route->getId());
}
} Try / catch
try { $compiled = $dumper->dump(); } catch (RouteNotFoundException $e) { // dangling alias
// identify and fix the alias before caching
} Prevention
- When renaming routes, update all aliases in the same change
- Grep config for old route ids after deletions
- Add a kernel event/test validating all aliases resolve
When it happens
Trigger: A RouteCollection contains an Alias whose target id (after following chained aliases) is not present in $routes; triggered during getCompiledAliases while dumping the router (generateDeclaredRoutes/getGenerator).
Common situations: Renaming or deleting a route but leaving aliases pointing at the old id; chained aliases where an intermediate route was removed; config imports defining aliases to routes that never loaded.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Using "%% %%" is not allowed in routing configuration.
- The container parameter
- The container parameter
- Unable to generate a URL for the named route
- Unable to generate a URL for the named route
AI-assisted analysis of symfony/routing@83fa223250 (2026-09-14).
Data as JSON: /api/errors/9f07ce672dad581b.
Report an issue: GitHub.
Appendix: source
Thrown at Generator/Dumper/CompiledUrlGeneratorDumper.php:72
$visited = [];
while (null !== $alias = $routes->getAlias($currentId) ?? null) {
if (false !== $searchKey = array_search($currentId, $visited)) {
$visited[] = $currentId;
throw new RouteCircularReferenceException($currentId, \array_slice($visited, $searchKey));
}
if ($alias->isDeprecated()) {
$deprecations[] = $deprecation = $alias->getDeprecation($currentId);
trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']);
}
$visited[] = $currentId;
$currentId = $alias->getId();
}
if (null === $target = $routes->get($currentId)) {
throw new RouteNotFoundException(\sprintf('Target route "%s" for alias "%s" does not exist.', $currentId, $name));
}
$compiledTarget = $target->compile();
$defaults = $target->getDefaults();
if (isset($defaults['_locale']) && str_ends_with($name, '.'.$defaults['_locale'])) {
$defaults['_canonical_route'] = substr($name, 0, -\strlen($defaults['_locale']) - 1);
}
$compiledAliases[$name] = [
$compiledTarget->getVariables(),
$defaults,
$target->getRequirements(),
$compiledTarget->getTokens(),
$compiledTarget->getHostTokens(),
$target->getSchemes(),
$deprecations,
];View on GitHub (pinned to 83fa223250)