microsoft/aspire · error · DistributedApplicationException
Could not create HTTP probe for resource
Error message
Could not create HTTP probe for resource '{builder.Resource.Name}' as the endpoint selector returned null. What it means
WithHttpProbe creates an HTTP probe (liveness/readiness/startup) for a resource by asking an endpoint selector for an EndpointReference. This DistributedApplicationException is thrown when that selector returns null, meaning there is no endpoint from which to build the probe. It guards against creating a probe annotation pointing at a nonexistent endpoint.
Solutions
- Ensure the resource has an HTTP endpoint registered (WithHttpEndpoint/WithHttpsEndpoint) before WithHttpProbe
- Fix or remove the custom endpointSelector so it returns a valid EndpointReference
- Check the endpoint exists in both run and publish modes if endpoints are conditional
Example fix
// before
var api = builder.AddProject<Projects.Api>("api")
.WithHttpProbe(ProbeType.Readiness, selector: e => null);
// after
var api = builder.AddProject<Projects.Api>("api")
.WithHttpEndpoint(port: 8080)
.WithHttpProbe(ProbeType.Readiness, path: "/health"); Defensive patterns
Strategy: validation
Validate before calling
EndpointReference? SelectEndpoint(IResourceBuilder<T> b) =>
b.Resource.Annotations.OfType<EndpointAnnotation>().Any()
? b.GetEndpoint("http")
: null;
if (SelectEndpoint(builder) is null) throw new InvalidOperationException("Resource has no endpoint for probes."); Try / catch
try { builder.WithHttpProbe(ProbeType.Readiness); }
catch (DistributedApplicationException ex) { logger.LogWarning(ex, "Probe skipped for {Resource}: no endpoint", builder.Resource.Name); } Prevention
- Register endpoints before adding probes
- Verify custom endpointSelector delegates return non-null for all launch modes
- Prefer the default selector only when the resource certainly has an HTTP endpoint
When it happens
Trigger: Calling WithHttpProbe with a custom endpointSelector delegate that returns null, or with the default selector when the resource has no matching HTTP endpoint. Passing null for endpointSelector uses DefaultEndpointSelector, which can still yield null.
Common situations: Adding probes to a resource before any endpoint is registered, a selector filtering on an endpoint name/scheme that does not exist, or conditional endpoint registration (publish-only endpoints).
Related errors
- Could not create HTTP command for resource
- AllocatedEndpoint must use the same network as the…
- Cannot find a http or https endpoint for this resource.
- Endpoint ' ' for resource ' ' not found.
- Endpoint ' ' must specify a port for scheme ' '.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/a4e6cf62f7c32909.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/ResourceBuilderExtensions.cs:5115
/// .WithHttpProbe(ProbeType.Liveness, "/health");
/// </code>
/// Is the same of writing:
/// <code lang="C#">
/// var service = builder.AddProject<Projects.MyService>("service")
/// .WithHttpProbe(ProbeType.Liveness, "/health")
/// .WithHttpHealthCheck("/health");
/// </code>
/// </example>
/// <para>This method is not available in polyglot app hosts. Use the endpointName-based overload instead.</para>
/// </remarks>
[Experimental("ASPIREPROBES001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")]
[AspireExportIgnore(Reason = "Func<EndpointReference> delegate — not ATS-compatible.")]
public static IResourceBuilder<T> WithHttpProbe<T>(this IResourceBuilder<T> builder, ProbeType type, Func<EndpointReference>? endpointSelector, string? path = null, int? initialDelaySeconds = null, int? periodSeconds = null, int? timeoutSeconds = null, int? failureThreshold = null, int? successThreshold = null)
where T : IResourceWithEndpoints, IResourceWithProbes
{
endpointSelector ??= DefaultEndpointSelector(builder);
var endpoint = endpointSelector() ?? throw new DistributedApplicationException($"Could not create HTTP probe for resource '{builder.Resource.Name}' as the endpoint selector returned null.");
var endpointProbeAnnotation = new EndpointProbeAnnotation
{
Type = type,
EndpointReference = endpoint,
Path = path ?? "/",
InitialDelaySeconds = initialDelaySeconds ?? 5,
PeriodSeconds = periodSeconds ?? 5,
TimeoutSeconds = timeoutSeconds ?? 1,
FailureThreshold = failureThreshold ?? 3,
SuccessThreshold = successThreshold ?? 1,
};
return builder
.WithProbe(endpointProbeAnnotation)
.WithHttpHealthCheck(endpointSelector, path);
}
/// <summary>View on GitHub (pinned to 25830f84bd)