microsoft/aspire · error · ArgumentException
Resource ' ' has no allocated endpoints.
Error message
Resource '{0}' has no allocated endpoints. What it means
GetEndpointUriStringCore throws this ArgumentException when the resolved resource does not implement IResourceWithEndpoints, meaning no endpoints have been (or can be) allocated for it. Despite the message text, the immediate condition is a type mismatch: the resource cannot expose endpoint references at all.
Solutions
- Call GetEndpoint on the project or container resource that declares endpoints (e.g. the web frontend)
- Add an endpoint to the resource in the AppHost (WithEndpoint/WithHttpEndpoint) if it should expose one
- Check resource type with app.GetResource(name) before requesting an endpoint
Example fix
// before
var url = app.GetEndpoint("postgres"); // no endpoints
// after
var url = app.GetEndpoint("frontend", "https"); Defensive patterns
Strategy: type-guard
Validate before calling
var resource = app.GetResource(name); bool hasEndpoints = resource is IResourceWithEndpoints;
Type guard
static bool HasEndpoints(DistributedApplication app, string name) =>
app.GetResource(name) is IResourceWithEndpoints; Try / catch
try { var url = app.GetEndpoint(name); }
catch (ArgumentException ex) when (ex.Message.Contains("endpoints"))
{
// resource cannot expose endpoints; target the right resource
} Prevention
- Only request endpoints from project/container/executable resources
- Add WithHttpEndpoint in the AppHost when an endpoint is needed
- Verify the resource type before calling GetEndpoint
When it happens
Trigger: Calling app.GetEndpoint("projectName") (or GetEndpointUriStringCore via GetEndpointForNetwork) on a resource that is not a project/executable/container with endpoint annotations — e.g. a database or parameter resource.
Common situations: Passing a database/queue resource name to GetEndpoint instead of a web project; custom resource types lacking EndpointAnnotation; misremembering which resource owns the HTTP endpoint.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Endpoint ' ' for resource ' ' not found.
- 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/87327f26ea4f2876.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Testing/DistributedApplicationHostingTestingExtensions.cs:270
static IResource GetResource(DistributedApplication app, string resourceName)
{
ThrowIfNotStarted(app, Properties.Resources.ApplicationNotStartedExceptionMessage);
var applicationModel = app.Services.GetRequiredService<DistributedApplicationModel>();
if (!applicationModel.Resources.TryGetByName(resourceName, out var resource))
{
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.ResourceNotFoundExceptionMessage, resourceName), nameof(resourceName));
}
return resource;
}
static string GetEndpointUriStringCore(DistributedApplication app, string resourceName, string? endpointName = default, NetworkIdentifier? networkIdentifier = default)
{
var resource = GetResource(app, resourceName);
if (resource is not IResourceWithEndpoints resourceWithEndpoints)
{
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));
}View on GitHub (pinned to 25830f84bd)