microsoft/aspire · error · ArgumentException
Endpoint ' ' for resource ' ' not found.
Error message
Endpoint '{0}' for resource '{1}' not found. What it means
GetEndpointUriStringCore throws this ArgumentException when the requested endpoint name (or the implicit https/http fallback) cannot be resolved on the resource. After trying the explicit name or the https-then-http default pair, no EndpointReference matches, so the library fails fast.
Solutions
- Use an endpoint name that the resource actually defines (check WithEndpoint/WithHttpEndpoint calls in the AppHost)
- If the project is http-only, request "http" explicitly or omit scheme assumptions
- Add the missing endpoint in the AppHost if the test legitimately needs it
Example fix
// before
var url = app.GetEndpoint("frontend", "https"); // http-only project
// after
var url = app.GetEndpoint("frontend", "http"); Defensive patterns
Strategy: validation
Validate before calling
var res = (IResourceWithEndpoints)app.GetResource(name); var endpoints = ((IResource)r).Annotations.OfType<EndpointAnnotation>().Select(a => a.Name).ToList(); // ensure desired endpoint name is in endpoints before calling GetEndpoint
Try / catch
try { var url = app.GetEndpoint(name, endpointName); }
catch (ArgumentException ex) when (ex.Message.Contains("not found"))
{
// fall back to the other scheme or a different endpoint name
} Prevention
- Check WithEndpoint/WithHttpEndpoint names in the AppHost before hardcoding endpoint names
- Remember the default fallback tries https then http only
- For http-only projects request "http" explicitly
When it happens
Trigger: Calling app.GetEndpoint("frontend", "https") when the project only defines an http endpoint; calling without an endpoint name on a resource that has neither https nor http endpoints; using a custom endpoint name not registered via WithEndpoint.
Common situations: Projects configured http-only being asked for https; endpoint renamed in the AppHost (WithEndpoint(name: ...)) but tests still use the old name; endpoints only added conditionally.
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
- Resource ' ' has no allocated endpoints.
- Resource ' ' does not expose a connection string.
- Resource ' ' not found.
- AllocatedEndpoint must use the same network as the…
- Array params contains empty item
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/f40a57eecbe9886e.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Testing/DistributedApplicationHostingTestingExtensions.cs:287
{
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.ResourceHasNoAllocatedEndpointsExceptionMessage, resourceName), nameof(resourceName));
}
EndpointReference? endpoint;
if (!string.IsNullOrEmpty(endpointName))
{
endpoint = GetEndpointOrDefault(resourceWithEndpoints, endpointName, networkIdentifier);
}
else
{
// Prefer https over http to match the default service discovery behavior (https+http://),
// where https is tried first.
endpoint = GetEndpointOrDefault(resourceWithEndpoints, "https", networkIdentifier) ?? GetEndpointOrDefault(resourceWithEndpoints, "http", networkIdentifier);
}
if (endpoint is null)
{
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.EndpointForResourceNotFoundExceptionMessage, endpointName, resourceName), nameof(endpointName));
}
return endpoint.Url;
}
static void ThrowIfNotStarted(DistributedApplication app, string exceptionMessage)
{
var lifetime = app.Services.GetRequiredService<IHostApplicationLifetime>();
if (!lifetime.ApplicationStarted.IsCancellationRequested)
{
throw new InvalidOperationException(exceptionMessage);
}
}
static EndpointReference? GetEndpointOrDefault(IResourceWithEndpoints resourceWithEndpoints, string endpointName, NetworkIdentifier? networkIdentifier = default)
{
var reference = resourceWithEndpoints.GetEndpoint(endpointName, networkIdentifier ?? KnownNetworkIdentifiers.LocalhostNetwork);
View on GitHub (pinned to 25830f84bd)