{"record":{"id":"c3a6420944ea0dfa","repo":"microsoft/aspire","slug":"the-endpoint-endpointname-does-not-exist-on-the-resource","errorCode":null,"errorMessage":"The endpoint '{endpointName}' does not exist on the resource '{builder.Resource.Name}'.","messagePattern":"The endpoint '(.+?)' does not exist on the resource '(.+?)'\\.","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/ResourceBuilderExtensions.cs","lineNumber":2826,"sourceCode":"        var endpoint = endpointSelector()\n            ?? throw new DistributedApplicationException($\"Could not create HTTP health check for resource '{builder.Resource.Name}' as the endpoint selector returned null.\");\n\n        if (endpoint.Scheme != \"http\" && endpoint.Scheme != \"https\")\n        {\n            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.\");\n        }\n\n        path ??= \"/\";\n        statusCode ??= 200;\n\n        var endpointName = endpoint.EndpointName;\n\n        // Validate that the endpoint exists during allocation to fail fast on misconfiguration.\n        builder.OnResourceEndpointsAllocated((_, @event, ct) =>\n        {\n            if (!endpoint.Exists)\n            {\n                throw new DistributedApplicationException($\"The endpoint '{endpointName}' does not exist on the resource '{builder.Resource.Name}'.\");\n            }\n\n            return Task.CompletedTask;\n        });\n\n        var healthCheckKey = $\"{builder.Resource.Name}_{endpointName}_{path}_{statusCode}_check\";\n\n        builder.ApplicationBuilder.Services.AddHttpClient();\n        builder.ApplicationBuilder.Services.SuppressHealthCheckHttpClientLogging(healthCheckKey);\n\n        builder.ApplicationBuilder.Services.AddHealthChecks().Add(new HealthCheckRegistration(\n            healthCheckKey,\n            serviceProvider => new EndpointUriHealthCheck(\n                endpoint,\n                path,\n                statusCode.Value,\n                () => serviceProvider.GetRequiredService<IHttpClientFactory>().CreateClient(healthCheckKey)),\n            failureStatus: default,","sourceCodeStart":2808,"sourceCodeEnd":2844,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/ResourceBuilderExtensions.cs#L2808-L2844","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nvar api = builder.AddProject<Projects.Api>(\"api\")\n    .WithHttpEndpoint(name: \"web\");\napi.WithHttpHealthCheck(\"http\"); // throws: 'http' not allocated\n\n// after\nvar api = builder.AddProject<Projects.Api>(\"api\")\n    .WithHttpEndpoint(name: \"web\");\napi.WithHttpHealthCheck(\"web\");","handlingStrategy":"try-catch","validationCode":"var names = resource.Annotations.OfType<EndpointAnnotation>().Select(e => e.Name);\nif (!names.Contains(endpointName))\n    Console.Warn($\"Endpoint '{endpointName}' not declared on resource.\");","typeGuard":"bool EndpointDeclared(IResource r, string name) => r.Annotations.OfType<EndpointAnnotation>().Any(e => string.Equals(e.Name, name, StringComparison.OrdinalIgnoreCase));","tryCatchPattern":"try { appHost.Run(); }\ncatch (DistributedApplicationException ex) when (ex.Message.Contains(\"does not exist on the resource\"))\n{ Console.Error.WriteLine($\"Fix endpoint name: {ex.Message}\"); throw; }","preventionTips":["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."],"tags":["aspire","health-check","endpoint","resource-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}