microsoft/aspire · error · DistributedApplicationException
The endpoint ' ' does not exist on the resource ' '.
Error message
The endpoint '{endpointName}' does not exist on the resource '{builder.Resource.Name}'. What it means
Thrown from the OnResourceEndpointsAllocated callback registered by WithHttpHealthCheck when, after endpoint allocation, endpoint.Exists is false — i.e. the endpoint name referenced by the health check was never allocated on the resource. Aspire validates late (during allocation) to fail fast on misconfiguration before the health check runs.
Solutions
- Ensure the endpoint with that name exists: add WithHttpEndpoint(name: ...)/WithEndpoint matching the health-check name.
- Update the health-check call to use the current endpoint name after renames.
- Remove environment-conditional endpoint creation or make the health check conditional too.
- Run the AppHost and check allocated endpoints in the dashboard to confirm the name/scheme.
Example fix
// before
var api = builder.AddProject<Projects.Api>("api")
.WithHttpEndpoint(name: "web");
api.WithHttpHealthCheck("http"); // throws: 'http' not allocated
// after
var api = builder.AddProject<Projects.Api>("api")
.WithHttpEndpoint(name: "web");
api.WithHttpHealthCheck("web"); Defensive patterns
Strategy: try-catch
Validate before calling
var names = resource.Annotations.OfType<EndpointAnnotation>().Select(e => e.Name);
if (!names.Contains(endpointName))
Console.Warn($"Endpoint '{endpointName}' not declared on resource."); Type guard
bool EndpointDeclared(IResource r, string name) => r.Annotations.OfType<EndpointAnnotation>().Any(e => string.Equals(e.Name, name, StringComparison.OrdinalIgnoreCase));
Try / catch
try { appHost.Run(); }
catch (DistributedApplicationException ex) when (ex.Message.Contains("does not exist on the resource"))
{ Console.Error.WriteLine($"Fix endpoint name: {ex.Message}"); throw; } Prevention
- Keep endpoint names as constants shared between WithEndpoint and WithHttpHealthCheck calls.
- After renaming endpoints, grep the AppHost for the old name.
- Check the dashboard's allocated endpoints when health checks fail to wire.
When it happens
Trigger: WithHttpHealthCheck(endpointName) where the named endpoint doesn't exist on the resource; endpoint declared conditionally (only in some environments); endpoint removed/renamed while the health check still references the old name; scheme/name mismatch so no matching endpoint is allocated.
Common situations: Renaming an endpoint in the AppHost but not the health-check call; environment-specific endpoint creation; project references a port/endpoint that only exists in another project.
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
- Could not create HTTP health check for resource
- Could not create HTTP health check for resource
- Connection string is unavailable
- Connection string is unavailable
- Connection string is unavailable
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/c3a6420944ea0dfa.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/ResourceBuilderExtensions.cs:2826
var endpoint = endpointSelector()
?? throw new DistributedApplicationException($"Could not create HTTP health check for resource '{builder.Resource.Name}' as the endpoint selector returned null.");
if (endpoint.Scheme != "http" && endpoint.Scheme != "https")
{
throw new DistributedApplicationException($"Could not create HTTP health check for resource '{builder.Resource.Name}' as the endpoint with name '{endpoint.EndpointName}' and scheme '{endpoint.Scheme}' is not an HTTP endpoint.");
}
path ??= "/";
statusCode ??= 200;
var endpointName = endpoint.EndpointName;
// Validate that the endpoint exists during allocation to fail fast on misconfiguration.
builder.OnResourceEndpointsAllocated((_, @event, ct) =>
{
if (!endpoint.Exists)
{
throw new DistributedApplicationException($"The endpoint '{endpointName}' does not exist on the resource '{builder.Resource.Name}'.");
}
return Task.CompletedTask;
});
var healthCheckKey = $"{builder.Resource.Name}_{endpointName}_{path}_{statusCode}_check";
builder.ApplicationBuilder.Services.AddHttpClient();
builder.ApplicationBuilder.Services.SuppressHealthCheckHttpClientLogging(healthCheckKey);
builder.ApplicationBuilder.Services.AddHealthChecks().Add(new HealthCheckRegistration(
healthCheckKey,
serviceProvider => new EndpointUriHealthCheck(
endpoint,
path,
statusCode.Value,
() => serviceProvider.GetRequiredService<IHttpClientFactory>().CreateClient(healthCheckKey)),
failureStatus: default,View on GitHub (pinned to 25830f84bd)