microsoft/aspire · error · InvalidDataException
Service ' ' refers to endpoint ' ' that does not exist
Error message
Service '{ts.Service!.Metadata.Name}' refers to endpoint '{ts.EndpointName}' that does not exist What it means
A container tunnel Service references an endpoint by name that cannot be found on the target resource. Tunnels are built from an endpoint of the model resource, so a missing endpoint means the tunnel annotation and the resource's endpoint set are out of sync — an internal consistency failure.
Solutions
- Ensure the endpoint name referenced by the tunnel exists on the resource (check WithEndpoint names).
- Rebuild/restart the AppHost so tunnel metadata regenerates after endpoint changes.
- Clean stale artifacts (bin/obj, aspire cache) and update Aspire packages if it persists.
Example fix
// before
.WithEndpoint("https", e => { ... }) // tunnel still references "http"
// after
.WithEndpoint("http", e => { ... }) // name matches the endpoint the tunnel refers to Defensive patterns
Strategy: validation
Validate before calling
var tunnelEndpointNames = tunnelAnnotations.Select(t => t.EndpointName);
var resourceEndpoints = resource.Annotations.OfType<EndpointAnnotation>().Select(e => e.Name);
var missing = tunnelEndpointNames.Except(resourceEndpoints).ToList();
if (missing.Count > 0) throw new InvalidOperationException($"Tunnel references missing endpoints: {string.Join(',', missing)}"); Try / catch
try
{
app.Run();
}
catch (InvalidDataException ex) when (ex.Message.Contains("refers to endpoint") && ex.Message.Contains("does not exist"))
{
// fix the endpoint name or rebuild to regenerate tunnel metadata
} Prevention
- Treat endpoint names as contracts: rename them everywhere (including tunnel/proxy wiring) atomically.
- Rebuild the AppHost (clean bin/obj) after endpoint renames.
- Prefer constants/shared names for endpoints consumed across resources.
When it happens
Trigger: AddContainerTunnelAllocatedEndpoints iterates tunnel services and calls TryGetEndpoint(res, ts.EndpointName); the resource has no endpoint annotation with that name (renamed or removed endpoint, ordering bug, stale tunnel metadata).
Common situations: Renaming an endpoint used by WithEndpoint on a resource consumed over the container network; removing an endpoint while tunnel/proxy wiring still references the old name; Aspire internal bugs in tunnel setup.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Container tunnel service
- Resource ' ' can have multiple replicas, and it uses…
- Resource ' ' uses multiple replicas and a proxy-less…
- Service ' ' needs to specify a port for endpoint ' ' since…
- The endpoint ' ' for resource ' ' requested a proxy…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/0b38cc39acaa69d3.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/Dcp/DcpModelUtilities.cs:300
var tunnelServices = allAppResources.Get().OfType<AppResource<Service>>().Select(r => (
Service: r.DcpResource,
ResourceName: r.DcpResource.Metadata.Annotations?.TryGetValue(CustomResource.ResourceNameAnnotation, out var resourceName) == true ? resourceName : null,
EndpointName: r.DcpResource.Metadata.Annotations?.TryGetValue(CustomResource.EndpointNameAnnotation, out var endpointName) == true ? endpointName : null,
TunnelInstanceName: r.DcpResource.Metadata.Annotations?.TryGetValue(CustomResource.ContainerTunnelInstanceName, out var tunnelInstanceName) == true ? tunnelInstanceName : null,
ContainerNetworkName: r.DcpResource.Metadata.Annotations?.TryGetValue(CustomResource.ContainerNetworkAnnotation, out var containerNetworkName) == true ? containerNetworkName : null
))
.Where(ts =>
ts.Service is not null &&
string.Equals(ts.ResourceName, res.Name, StringComparisons.ResourceName) &&
!string.IsNullOrEmpty(ts.EndpointName) &&
!string.IsNullOrEmpty(ts.ContainerNetworkName)
);
foreach (var ts in tunnelServices)
{
if (!TryGetEndpoint(res, ts.EndpointName, out var endpoint))
{
throw new InvalidDataException($"Service '{ts.Service!.Metadata.Name}' refers to endpoint '{ts.EndpointName}' that does not exist");
}
if (ts.Service?.HasCompleteAddress is not true)
{
// This should never happen; if it does, we have a bug without a workaround for the user.
throw new InvalidDataException($"Container tunnel service {ts.Service?.Metadata.Name} should have valid address at this point");
}
var serverSvc = allAppResources.Get().OfType<ServiceWithModelResource>().FirstOrDefault(swr =>
string.Equals(swr.ModelResource.Name, ts.ResourceName, StringComparisons.ResourceName) &&
string.Equals(swr.EndpointAnnotation.Name, endpoint.Name, StringComparisons.EndpointAnnotationName)
);
if (serverSvc is null)
{
// Should never happen -- we should have created a Service for every endpoint exposed from a resource.
throw new InvalidDataException($"The '{endpoint.Name}' on resource '{ts.ResourceName}' should have an associated DCP Service resource already set up");
}
View on GitHub (pinned to 25830f84bd)