Skip to content

[BUG]: Only one Dev Proxy instance should be the system proxy, but foreground starts and reloads can take it over #2203

Done

Description

@waldekmastykarz

Description

Only one Dev Proxy instance should be registered as the system proxy at a time. If another live instance already is, starting a new one as the system proxy should fail with an error.

Today this is only enforced for detached starts (DevProxy/Program.cs:63-78, using StateManager.FindSystemProxyInstanceAsync). Foreground starts don't check it, and neither does re-registering during a hot-reload restart. So a second instance can take over the system proxy, and SystemProxyManager has code that tolerates this (SystemProxyManager.cs:116, and the FindLiveSystemProxyOwnerAsync docs at line 584: "the latest instance to take over the system proxy rewrites it").

Expected behaviour

Every start path that would register the system proxy (detached, foreground, and hot-reload re-registration) fails with the same error when another live process owns the system proxy, for example "Dev Proxy is already running as system proxy (PID: …). Use 'devproxy stop' to stop it first." The owner check should cover both foreground and detached owners, for example via the snapshot's owning PID (FindLiveSystemProxyOwnerAsync). Leftovers from crashed instances should still be handled by orphan recovery rather than blocking.

Actual behaviour

A foreground instance started with --as-system-proxy true registers as the system proxy even while another live instance owns it, overwriting the snapshot and taking over.

Steps to reproduce

  1. On macOS or Windows, run devproxy in the foreground as the system proxy.
  2. In another terminal, run a second devproxy in the foreground as the system proxy, on a different port.
  3. The second instance registers and takes over instead of failing.

Dev Proxy Version

main

Operating system (environment)

macOS

Shell

zsh

Configuration file

N/A

Additional Info

Came up while reviewing #2149. That PR is being changed so that a hot-reload never takes the system proxy back from another owner. This issue covers enforcing the single-owner rule across all start paths.

Activity

  1. added a commit that references this issue on Dec 3, 2026
    5975ef0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions