Skip to content

Print proxy URL when starting Dev Proxy in detach mode#1591

Open
Copilot wants to merge 6 commits intomainfrom
copilot/print-assigned-port-number
Open

Print proxy URL when starting Dev Proxy in detach mode#1591
Copilot wants to merge 6 commits intomainfrom
copilot/print-assigned-port-number

Conversation

Copy link
Contributor

Copilot AI commented Mar 5, 2026

devproxy --port 0 --detach didn't show the assigned proxy port, making the proxy unusable since the caller can't know where to connect.

  • ProxyEngine: After StartAsync(), update _config.Port from the actual endpoint port (resolves OS-assigned port for --port 0). Re-save state file when running as daemon so the parent process picks up the resolved value.
  • Program.cs: Add Proxy URL line between PID and API URL in detach output. Wait for state.Port > 0 instead of just state existence to avoid reading stale port 0 before the engine updates it.
Dev Proxy started in background.

  PID:       6456
  Proxy URL: http://127.0.0.1:34251
  API URL:   http://127.0.0.1:8897
  Log file:  /Users/user/.config/dev-proxy/logs/devproxy-6456-2026-03-05.log

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy --as-system-proxy false --port 0 --api-port 0 --_internal-daemon (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy stop (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy --as-system-proxy false --port 8000 --api-port 0 --_internal-daemon (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Print port number when starting Dev Proxy in detach mode</issue_title>
<issue_description>When you start Dev Proxy using devproxy --port 0 --output json --detach it shows the following output:

Dev Proxy started in background.

  PID:       6456
  API URL:   http://127.0.0.1:8897
  Log file:  C:\Users\scope\AppData\Local\dev-proxy\logs\devproxy-6456-2026-03-05-14-22-42.log

Use 'devproxy status' to check status.
Use 'devproxy logs' to view logs.
Use 'devproxy stop' to stop.

--port 0 means that a random port should be assigned to Dev Proxy. The output however doesn't show which port was assigned making it impossible to use Dev Proxy.

Between PID and API URL print the actual proxy URL and assigned port (even when explicitly specified through args)</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…mode

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copilot AI changed the title [WIP] Print assigned port number when starting Dev Proxy in detach mode Print proxy URL when starting Dev Proxy in detach mode Mar 5, 2026
@waldekmastykarz waldekmastykarz marked this pull request as ready for review March 5, 2026 15:01
@waldekmastykarz waldekmastykarz requested a review from a team as a code owner March 5, 2026 15:01
Copilot AI review requested due to automatic review settings March 5, 2026 15:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves detached-mode startup output so callers can discover the actual proxy address when using OS-assigned ports (--port 0), by persisting the resolved proxy port and printing a Proxy URL in the parent process.

Changes:

  • Update ProxyEngine to set the runtime port after the proxy endpoint is started, and (when running as the internal daemon) re-save the detached state file with the resolved port.
  • Update detached-mode startup polling to wait for state.Port > 0 and print a new Proxy URL: line in the console output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
DevProxy/Proxy/ProxyEngine.cs After starting the proxy endpoint, updates the effective port and re-saves detached state with the resolved port for --port 0.
DevProxy/Program.cs In detached startup output, waits for a non-zero port and prints the resolved Proxy URL alongside PID/API URL/log file.

You can also share your feedback on Copilot code review. Take the survey.

waldekmastykarz and others added 2 commits March 5, 2026 16:09
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

Print port number when starting Dev Proxy in detach mode

3 participants