microsoft/aspire · error · InvalidDataException
Service should have valid address at this point
Error message
Service {svc.Metadata.Name} should have valid address at this point What it means
This is an internal-invariant failure: DCP Service objects should always have a complete allocated address before this code runs, because the model builder waits for addresses before processing. A null/empty svc.AllocatedAddress here means an internal bug or race, not a user-actionable configuration problem.
Solutions
- Restart the AppHost and the Aspire environment (aspire run again) to reset DCP allocation state.
- Check dashboard/DCP logs for the named Service to see why allocation never completed (e.g. port pool exhaustion, docker failure).
- Update Aspire packages; if reproducible, file a bug — the code comments explicitly say 'we have a bug without a workaround'.
Defensive patterns
Strategy: try-catch
Try / catch
try
{
await appHost.StartAsync();
}
catch (InvalidDataException ex) when (ex.Message.Contains("should have valid address at this point"))
{
// restart DCP/AppHost; if reproducible, report an Aspire bug with DCP logs
} Prevention
- Keep the container runtime and DCP healthy (restart docker if allocation stalls).
- Avoid deleting/restarting resources while the AppHost model is still building.
- Update Aspire packages regularly; this path is by-design unreachable.
When it happens
Trigger: TryAddLocalhostAllocatedEndpoint is called (via TryAddWorkloadAllocatedEndpoints or ApplyServiceAddressToEndpoint) with allowPending=false while svc.AllocatedAddress is null/empty — i.e. the DCP Service was expected to have finished port allocation but did not.
Common situations: A slow or wedged DCP/docker environment where the service never completed allocation; a race where a resource was deleted or restarted mid-model-build; genuine Aspire/DCP bugs.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Container tunnel service
- The ' ' on resource ' ' should have an associated DCP…
- ConnectionStringAvailableEvent was published for the
- Failed to get or create property
- Resource ' ' can have multiple replicas, and it uses…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/818281bf88c73319.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/Dcp/DcpModelUtilities.cs:181
{
var svc = sp.DcpResource;
var allocatedPort = svc.AllocatedPort ?? fallbackPort;
if (sp.EndpointAnnotation.AllocatedEndpoint is not null)
{
return true;
}
if (!svc.HasCompleteAddress && sp.EndpointAnnotation.IsProxied)
{
if (allowPending)
{
return false;
}
// This should never happen; if it does, we have a bug without a workaround for the user.
// We should have waited for the service to have a complete address before getting here.
throw new InvalidDataException($"Service {svc.Metadata.Name} should have valid address at this point");
}
if (!sp.EndpointAnnotation.IsProxied && allocatedPort is null)
{
if (allowPending)
{
return false;
}
throw new InvalidOperationException($"Service '{svc.Metadata.Name}' needs to specify a port for endpoint '{sp.EndpointAnnotation.Name}' since it isn't using a proxy.");
}
if (allocatedPort is null || string.IsNullOrEmpty(svc.AllocatedAddress))
{
if (allowPending)
{
return false;
}View on GitHub (pinned to 25830f84bd)