Skip to content

[release/13.4] Fix resource service port collision in --isolated mode#18341

Merged
joperezr merged 7 commits into
release/13.4from
backport/pr-18332-to-release/13.4
Jun 19, 2026
Merged

[release/13.4] Fix resource service port collision in --isolated mode#18341
joperezr merged 7 commits into
release/13.4from
backport/pr-18332-to-release/13.4

Conversation

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Backport of #18332 to release/13.4

/cc @davidfowl @JamesNK

Customer Impact

Testing

Risk

Regression?

JamesNK added 7 commits June 19, 2026 17:23
When running multiple instances with --isolated, the AppHost's dashboard,
resource service, and OTLP endpoints all tried to bind to the same fixed
ports from the launch profile/user secrets. Fix by clearing port-bearing
env vars (ASPNETCORE_URLS, ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL, and
ASPIRE_DASHBOARD_OTLP_*_ENDPOINT_URL) in ConfigureIsolatedModeAsync so
the AppHost falls back to OS-assigned random ports.

Also suppress the launch profile in the dotnet-run fallback path when
isolated, so the fixed ports from the profile don't leak through.
… true

When DcpPublisher:RandomizePorts is enabled (e.g. --isolated mode), the
DashboardServiceHost now ignores the fixed port from
ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL and binds to port 0 instead. This
allows multiple isolated instances of the same project to run concurrently
without port conflicts on the resource service endpoint.
Copilot AI review requested due to automatic review settings June 19, 2026 17:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://github.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18341

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18341"

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@joperezr joperezr merged commit 553a200 into release/13.4 Jun 19, 2026
623 of 627 checks passed
@joperezr joperezr deleted the backport/pr-18332-to-release/13.4 branch June 19, 2026 18:24
@github-actions github-actions Bot added this to the 13.4.x milestone Jun 19, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot removed this from the 13.4.x milestone Jun 19, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor Author

✅ No documentation update needed.

docs_optional → bug_fix_restores_documented_behavior

No signals were triggered (signal_count == 0). The one source-file change (src/Aspire.Hosting/Dashboard/DashboardServiceHost.cs) fixes a port-collision bug in --isolated mode, and the remaining four changed files are all under tests/.

The existing microsoft/aspire.dev documentation already correctly describes the intended behavior of --isolated:

  • reference/cli/commands/aspire-run.mdx (line 82): "Run in isolated mode with randomized ports and isolated user secrets, allowing multiple instances of the same AppHost to run simultaneously."
  • reference/cli/commands/aspire-start.mdx (line 95): same description.
  • whats-new/aspire-13-2.mdx (line 193): "The new --isolated flag runs an apphost with randomized ports and isolated user secrets, preventing port conflicts and configuration collisions."

The bug was that DashboardServiceHost.ConfigureKestrel did not honor DcpOptions.RandomizePorts for the resource-service endpoint, so a fixed port from ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL was used instead of port 0. This caused "address already in use" errors when a second instance tried to bind the same port. The fix makes the resource service respect the randomize-ports flag — restoring the already-documented behavior. No documentation update is needed.

This was referenced Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants