{"id":369,"date":"2026-04-09T10:00:00","date_gmt":"2026-04-09T17:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/aspire\/?p=369"},"modified":"2026-04-09T13:38:42","modified_gmt":"2026-04-09T20:38:42","slug":"aspire-isolated-mode-parallel-development","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/aspire\/aspire-isolated-mode-parallel-development\/","title":{"rendered":"Running Multiple Instances of an Aspire AppHost Without Port Conflicts"},"content":{"rendered":"<p>Running multiple instances of the same source code in parallel is increasingly common \u2014 especially with agentic development. Tools like VS Code Copilot&#8217;s background agent create git worktrees to work on your code independently, AI agents spin up separate environments to test different approaches, and developers use multiple checkouts to work across feature branches simultaneously.<\/p>\n<p>This creates a fundamental problem: applications bind to specific ports, and two instances of the same app fight over the same ones. The second instance fails with a port conflict. You&#8217;re stuck manually reassigning ports, juggling environment variables, or shutting things down to switch contexts.<\/p>\n<p>Aspire 13.2 solves this with <strong>isolated mode<\/strong> \u2014 a new <code>--isolated<\/code> flag that gives each run its own random ports and separate configuration, so multiple instances of the same AppHost just work.<\/p>\n<h2>The Problem: Port Collisions in Parallel Development<\/h2>\n<p>By default, Aspire runs services on predictable ports. When you start an AppHost:<\/p>\n<pre><code class=\"language-bash\">aspire run<\/code><\/pre>\n<p>It binds to specific ports defined in your dashboard config. If you have two instances of an Aspire project open and try to run both, the second one fails:<\/p>\n<pre><code>Error: Port 17370 is already in use by another application<\/code><\/pre>\n<p>This blocks common development scenarios:<\/p>\n<ul>\n<li><strong>Working across multiple checkouts<\/strong>: You&#8217;ve cloned the same repo into two directories (or are using git worktrees) and need to run the AppHost from both at the same time.<\/li>\n<li><strong>Integration tests<\/strong>: You want to run tests against a live AppHost while continuing to develop.<\/li>\n<li><strong>AI-assisted development<\/strong>: Agents spinning up multiple Aspire instances to test different configurations.<\/li>\n<\/ul>\n<p>The workaround was tedious: manually reassign ports, manage environment variables, or restart everything to switch projects.<\/p>\n<h2>The Solution: Isolated Mode<\/h2>\n<p>Aspire 13.2 introduces the <code>--isolated<\/code> option to <code>aspire run<\/code> and <code>aspire start<\/code>. This CLI option does two things:<\/p>\n<ol>\n<li><strong>Assigns random ports<\/strong> \u2014 Each instance gets its own port range, eliminating collisions.<\/li>\n<li><strong>Creates isolated user secrets<\/strong> \u2014 Configuration stays separate, preventing cross-instance contamination.<\/li>\n<\/ol>\n<p>Run it:<\/p>\n<pre><code class=\"language-bash\">aspire run --isolated<\/code><\/pre>\n<p>That&#8217;s it. No manual port configuration. No environment variable juggling. Each run gets a fresh, collision-free environment.<\/p>\n<h2>Real Scenarios<\/h2>\n<h3>Scenario 1: Working Across Multiple Checkouts<\/h3>\n<p>You&#8217;ve cloned the same repo into two directories \u2014 maybe one for a feature branch and another for a bug fix. Start the AppHost from the first checkout:<\/p>\n<pre><code class=\"language-bash\">cd ~\/projects\/my-app-feature\naspire run --isolated<\/code><\/pre>\n<p>In another terminal, start the same AppHost from the second checkout:<\/p>\n<pre><code class=\"language-bash\">cd ~\/projects\/my-app-bugfix\naspire run --isolated<\/code><\/pre>\n<p>Both run without conflicts. Each gets randomized ports. The dashboard still shows you what&#8217;s running and where, but you&#8217;re not fighting over the same ports.<\/p>\n<h3>Scenario 2: Background Agents in VS Code Copilot Chat<\/h3>\n<p>When you use <strong>Copilot Chat&#8217;s background agent<\/strong> in VS Code, it automatically creates a git worktree in a separate directory so it can work on your code without interfering with your current session. If your project includes an Aspire AppHost, the agent may need to run it \u2014 but you&#8217;re already running the same AppHost in your primary worktree. Without isolated mode, this causes a port collision.<\/p>\n<p>With <code>--isolated<\/code>, both instances just work:<\/p>\n<ul>\n<li><strong>Your main worktree<\/strong>: <code>aspire run --isolated<\/code> in your current checkout<\/li>\n<li><strong>The background agent&#8217;s worktree<\/strong>: <code>aspire run --isolated<\/code> in the auto-created worktree<\/li>\n<\/ul>\n<p>Each gets its own ports and secrets. You keep developing while the agent builds, tests, and iterates \u2014 all against the same AppHost, without conflicts.<\/p>\n<p>The Aspire skill that&#8217;s set up with <code>aspire agent init<\/code> instructs agents to use <code>--isolated<\/code> when using git worktrees. The Copilot agent should run your Aspire AppHost with isolation automatically.<\/p>\n<h2>How It Works Under the Hood<\/h2>\n<p>When you pass <code>--isolated<\/code>, the CLI generates a unique instance ID for the run. This ID drives two key behaviors:<\/p>\n<h3>Randomized Ports<\/h3>\n<p>Instead of binding to the predictable ports defined in your AppHost configuration, isolated mode selects random available ports for both the dashboard and all service endpoints. Where a normal run might bind services to ports 8080, 8081, and 8082, one isolated run might get 15234, 15235, and 15236 while another gets 22891, 22892, and 22893.<\/p>\n<p>The dashboard and service discovery automatically adjust \u2014 your code doesn&#8217;t need changes. Aspire&#8217;s service discovery resolves endpoints at runtime, so services find each other regardless of which ports they land on.<\/p>\n<h3>Isolated User Secrets<\/h3>\n<p>Each isolated run gets its own user secrets store, keyed by the instance ID. This means connection strings, API keys, and other configuration don&#8217;t leak between instances. If you&#8217;re testing with different Azure resources or database connections across two worktrees, each stays self-contained.<\/p>\n<p>The isolated secrets are stored alongside your normal user secrets but under a separate key, so they don&#8217;t interfere with your standard <code>aspire run<\/code> configuration.<\/p>\n<h2>When to Use Isolated Mode<\/h2>\n<p>Use it when:<\/p>\n<ul>\n<li>Running multiple instances of the same AppHost simultaneously<\/li>\n<li>Testing integration scenarios with a live AppHost while continuing to develop<\/li>\n<li>Running automated tests that need dedicated ports<\/li>\n<li>Working with tools or agents that spawn multiple instances of the same project<\/li>\n<li>Using git worktrees or multiple checkouts of the same repo<\/li>\n<\/ul>\n<p>You can still use the standard <code>aspire run<\/code> for single-project development if you prefer predictable ports.<\/p>\n<h2>Get Started<\/h2>\n<p><div  class=\"d-flex justify-content-center\"><a class=\"cta_button_link btn-primary mb-24\" href=\"https:\/\/aspire.dev\/get-started\/first-app\/\" target=\"_blank\">Try Aspire<\/a><\/div><\/p>\n<ul>\n<li><strong>\ud83d\udcd6 Learn more:<\/strong> Read the full documentation on <a href=\"https:\/\/aspire.dev\/reference\/cli\/overview\/\">Aspire CLI<\/a> at aspire.dev.<\/li>\n<li><strong>\ud83d\udcac Give us feedback:<\/strong> We&#8217;d love to hear what you think \u2014 file issues or join discussions on the <a href=\"https:\/\/github.com\/dotnet\/aspire\">Aspire GitHub repo<\/a>.<\/li>\n<li><strong>\ud83c\udf10 Join the community:<\/strong> Follow us and connect with other Aspire developers at <a href=\"https:\/\/aspire.dev\/community\/\">aspire.dev\/community<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Aspire 13.2 introduces isolated mode, letting you run multiple instances of the same AppHost in parallel without port conflicts. Learn how the &#8211;isolated flag solves development and testing workflows.<\/p>\n","protected":false},"author":11402,"featured_media":373,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,17],"tags":[26,9,10],"class_list":["post-369","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspire-category","category-deep-dives","tag-apphost","tag-aspire","tag-cli"],"acf":[],"blog_post_summary":"<p>Aspire 13.2 introduces isolated mode, letting you run multiple instances of the same AppHost in parallel without port conflicts. Learn how the &#8211;isolated flag solves development and testing workflows.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/aspire\/wp-json\/wp\/v2\/posts\/369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/aspire\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/aspire\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/aspire\/wp-json\/wp\/v2\/users\/11402"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/aspire\/wp-json\/wp\/v2\/comments?post=369"}],"version-history":[{"count":1,"href":"https:\/\/devblogs.microsoft.com\/aspire\/wp-json\/wp\/v2\/posts\/369\/revisions"}],"predecessor-version":[{"id":372,"href":"https:\/\/devblogs.microsoft.com\/aspire\/wp-json\/wp\/v2\/posts\/369\/revisions\/372"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/aspire\/wp-json\/wp\/v2\/media\/373"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/aspire\/wp-json\/wp\/v2\/media?parent=369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/aspire\/wp-json\/wp\/v2\/categories?post=369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/aspire\/wp-json\/wp\/v2\/tags?post=369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}