Cloud Agents: Port Forward localhost:P sticks to wrong/stale VM; Try Live correct, localhost serves old UI

Where does the bug appear (feature/product)?

Cursor CLI

Describe the Bug

With multiple Cloud Agent VMs (or after archiving/switching agents), Forwarded Ports → localhost:5173 does not reliably map to the active agent’s Vite. Try Live / in-VM desktop shows the correct app; localhost:5173 either refuses connection or serves an older checkout from another VM. Switching the agent tab alone does not rebind the tunnel.

Steps to Reproduce

Run Cloud Agent A with Vite on 0.0.0.0:5173 (feature X in UI).

Run Cloud Agent B with Vite on 0.0.0.0:5173 (feature Y / newer commit). Confirm Try Live on B shows Y.

In Desktop Ports, observe green 5173; open http://localhost:5173/…

Switch active tab between A and B (or archive A).

Observe localhost still shows A’s UI (or refuses / sticks), while Try Live on B remains

Expected Behavior

Opening agent A’s chat and forwarding port 5173 maps localhost:5173 to agent A’s process listening on 0.0.0.0:5173.

Switching to agent B (or archiving A) drops or rebinds the forward so localhost cannot silently hit a stale VM.

Auto-Forward does not keep a green 5173 mapping to a dead/archived/wrong agent while Try Live on another agent shows the real UI.

Actual

Try Live on the correct agent (bc-dae18f8f-…, Vite 0.0.0.0:5173, current main with MonthNavigator) → correct UI.

http://localhost:5173/books without forward → ERR_CONNECTION_REFUSED (−102). Expected if nothing is forwarded.

With Ports showing green 5173 → often old prototype (no month navigator), i.e. tunnel hits a different/older agent checkout.

Changing the active agent tab does not switch Forwarded Ports to that agent’s 5173.

Workaround of moving Vite to :5179 on the good agent was attempted; Ports still emphasized 5173 from elsewhere. Archiving the good agent then broke the intended stack entirely until a new agent was started.

Operating System

Windows 10/11

Version Information

Version: 3.25.6 (user setup)
VS Code Extension API: 1.128.0
Commit: f0df777c412b670d09e3eaf214967d779e67c080
Date: 2026-10-14T22:46:28.448Z
Layout: Agent Window
Build Type: Stable
Release Track: Default
Electron: 42.10.0
Chromium: 148.0.7778.280
Node.js: 24.18.1
V8: 14.8.178.38-electron.0
xterm.js: 6.1.0-beta.291
OS: Windows_NT x64 10.0.19045

For AI issues: which model did you use?

Auto

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey @Daniel14, thanks for the detailed report!

From what we can see, the agents you were testing are running inside a Project. In the current stable build, the Forwarded Ports menu in a Project stays attached to the Project’s main agent, not to the agent you’re viewing. So when you forward 5173 from there, localhost:5173 connects to a different VM than the one Try Live shows you, which lines up with the older UI you’re seeing. That’s also why switching between agents inside the Project doesn’t move the forward. This is a known issue, the team already has a fix on the way, and I’ve added your report to it.

Separately, when two agents forward the same port number, the newer forward can take over localhost for that port. I’ve flagged that to the team too.

In the meantime:

  1. Use Try Live (the in-VM desktop) to check each agent’s UI. It always shows that agent’s own VM.
  2. Before forwarding again, open the Ports menu and stop every existing forward, so nothing stale is still holding localhost:5173.
  3. For agents that are not inside a Project, give each dev server its own port (for example npm run dev -- --port 5181 --strictPort on one agent and 5182 on the other), so two agents never compete for the same local port.

Could you confirm two things for us?

  • Were agent A and agent B both inside the same Project, or were they separate agents in the sidebar?
  • When localhost:5173 showed the old UI, was the Project’s main agent (or another agent) also running a dev server on 5173?

Of course, I switched to using TryLive, although it’s very inconvenient.
Stopping and deleting ports has no effect — the autodetection mechanism stubbornly leads to the old code branch, and there’s no way to edit the port mapping.
To answer your question, I have only one agent that manages the project and creates sub‑agents on its own. I haven’t found any additional agents either in the client or in the web.
Two weeks ago, everything was working perfectly, and during that time two things happened:

  1. I went on vacation with another laptop and continued working on it. At the same time, the cursor client is closed on the other laptop (but that’s not certain). In any case, I have the same project in GitHub and cloud agents on both devices. Nothing local.
  2. The client has updated at least twice.

I can’t say exactly what is causing this system behavior.

Hey @Daniel14, thanks for checking, that answers it.

Since your main agent creates the sub-agents, they’re all part of one Project, so this is the issue I mentioned. In the current version, the Ports menu and Auto-Forward only ever connect to the main agent’s machine, never to the sub-agent you’re viewing. That’s also why it worked two weeks ago: back then you were using a single standalone agent, so its own machine was the one being forwarded.

The vacation laptop and the updates aren’t the cause. Port forwarding is set up separately by the Cursor app on each computer, so the other laptop can’t take over localhost on this one.

The reason stopping the port doesn’t stick: something on the main agent’s machine is still serving the older code on 5173 (the main agent itself, or a sub-agent that runs on the same machine). As long as that server is running, Auto-Forward finds it and forwards it again.

Until the fix reaches the stable version, these should help:

  1. Open the Ports menu (the plug icon at the top of the editor panel) and turn off “Auto-Forward Ports” at the bottom of the menu. That closes the automatic forwards and keeps them from coming back, including after switching agents or restarting Cursor.
  2. Ask the main Project agent to stop the dev server on port 5173 on its own machine, so there’s no old version left for localhost to land on.
  3. If you want the latest code on localhost right now, ask the main agent to check out the branch you want and start the dev server on its own machine. Because forwards currently go to the main agent’s machine, localhost:5173 will then show that version.

For a sub-agent’s own machine, Try Live is the only reliable view for now, sorry about the inconvenience. The change that makes the Ports menu follow the sub-agent you’re viewing is already done and will come in an upcoming update!

You’re absolutely right; I forgot one important detail — at first, I had one autonomous agent that was linked to the repo. Then I decided that this wasn’t in line with the cursor’s logic, archived it, and switched to working with the project’s orchestrator agent.
I think that if I had immediately taken the path of project orchestration, the entry barrier into Cursor would have been much higher. Because I moved the PostgreSQL DB to a VPS two weeks ago. I assume that otherwise, I would still have the problem of an empty DB in each individual agent VM.

In the end, I simply moved the entire stack and database to a VPS and solved the discrepancy issue that way.

As an idea, I would suggest giving users and/or agents the ability to manage custom port mapping. That would be a good feature.

In any case, thank you for your response and help.

Thanks for the follow-up, and glad the VPS setup got you unblocked. Keeping the stack and database in one place also avoids the empty-database-per-VM problem you mentioned, so that’s a solid setup for Projects.

Right now you can type any port number into the Ports menu to forward it manually, but you can’t choose the local port or which agent’s machine it points to, which is exactly the gap you hit. If you’d like other users to be able to upvote it, feel free to also post it in the Feature Requests category.

The change that makes the Ports menu follow the sub-agent you’re viewing is coming in an upcoming update (3.26)!