Skip to content

Improve Dev Proxy API port conflict handling with helpful error messages #1274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 25, 2025

When Dev Proxy tries to start and the API port (default 8897) is already in use, it previously showed an unhelpful error message with a long stack trace. This PR improves the user experience by providing clear, actionable guidance.

Changes Made

  • Added specific IOException handling for API port binding failures in DevProxyCommand.cs
  • When the API port is already in use, Dev Proxy now displays:
    • A clear error message indicating which port is blocked
    • Step-by-step resolution instructions
    • Example configuration showing how to set a custom API port
    • Reminder about updating Dev Proxy Toolkit extension settings if applicable

Before

fail    Hosting failed to start
      System.IO.IOException: Failed to bind to address http://127.0.0.1:8897: address already in use.
       ---> Microsoft.AspNetCore.Connections.AddressInUseException: Only one usage of each socket address...
       [Long stack trace continues...]

After

fail    Hosting failed to start
      [Stack trace for debugging...]
fail    Dev Proxy API port 8897 is already in use.
fail    To resolve this issue:
fail    1. Add the 'apiPort' property to your configuration file and set it to a different port number
fail    2. If you're using Dev Proxy Toolkit, update the API port extension setting to match your custom port
fail    Example configuration: { "apiPort": 8898 }

Testing

  • ✅ Verified normal startup when API port is available
  • ✅ Confirmed improved error message for default port (8897) conflicts
  • ✅ Tested with custom API port configurations
  • ✅ Ensured existing error handling for other exceptions remains unchanged
  • ✅ Build passes all analyzer checks

The changes are minimal and surgical - only 8 lines of new error handling code were added while preserving all existing functionality.

Fixes #1273.

Warning

Firewall rules blocked me from connecting to one or more addresses

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

  • aka.ms
    • Triggering command: curl -I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 REDACTED (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net9.0/devproxy --help (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net9.0/devproxy (dns block)

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


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits June 25, 2025 11:20
Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com>
Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Improve Dev Proxy API port conflict handling Improve Dev Proxy API port conflict handling with helpful error messages Jun 25, 2025
@Copilot Copilot AI requested a review from garrytrinder June 25, 2025 11:26
Copilot finished work on behalf of garrytrinder June 25, 2025 11:26
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.

Improve Dev Proxy API port conflict handling
2 participants