Skip to content

Followed instruction - DevProxy not intercepting localhost addresses #837

Closed

Description

@cfelstead

Hi,

I have looked at the instructions here and believe I am doing everything right. But I am not seeing any requests intercepted by devproxy that are on localhost addresses (public addresses are logged and intercepted correctly).

Configuration file (I've only added one new url)

{
  "$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v0.19.1/rc.schema.json",
  "plugins": [
    {
      "name": "RetryAfterPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll"
    },
    {
      "name": "GenericRandomErrorPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
      "configSection": "genericRandomErrorPlugin"
    }
  ],
  "urlsToWatch": [
    "https://localhost:7271/*",
    "https://jsonplaceholder.typicode.com/*"
  ],
  "genericRandomErrorPlugin": {
    "errorsFile": "devproxy-errors.json"
  },
  "rate": 50,
  "logLevel": "information",
  "newVersionNotification": "stable"
}

Starting visual studio and running my project in debug. Testing all is working correctly.

Starting devproxy via (actual path ommitted)
devproxy --config-file "C:\.....\devproxyrc.json"

Launching edge by doing Win + R and using the command
msedge --proxy-bypass-list="<-loopback>"
(have also tried replacing the <-loopback> with localhost and localhost:7271)

I'm sure I am missing something, but if I am, it is not clear what.
Help appreciated.

Activity

  1. garrytrinder commented on Jul 26, 2024

    @garrytrinder
    Collaborator

    Hey @cfelstead 👋

    Thanks for trying Dev Proxy, apologies for the trouble.

    Command-line options for proxy settings suggests that you also need to specify the --proxy-server option.

    --proxy-bypass-list=(<trailing_domain>|)[:][;...]

    Tells Microsoft Edge to bypass any specified proxy for the specified semicolon-separated list of hosts. This flag must be used with --proxy-server.

    Note

    Trailing-domain matching doesn't require "." separators, "microsoft.com" will match "imicrosoft.com". For example, --proxy-server="proxy2:8080" --proxy-bypass-list=".microsoft.com;*example.com;127.0.0.1:8080" will use the proxy server "proxy2" on port 8080 for all hosts except requests for *.microsoft.com, example.com, and 127.0.0.1 on port 8080. In the previous example, imicrosoft.com requests will still be proxied. However, iexample.com requests will bypass the proxy because *example.com was specified instead of *.example.com.

    Try adding the --proxy-server option to the command line arguments.

    msedge --proxy-bypass-list="<-loopback>" --proxy-server "127.0.0.1:8000"
    
  2. cfelstead commented on Jul 26, 2024

    @cfelstead
    Author

    Thanks @garrytrinder.

    Sadly no change. I am also trying via powershell using the below with no luck.
    curl -proxy http://127.0.0.1:8000 https://localhost:7271/Person

  3. garrytrinder commented on Jul 26, 2024

    @garrytrinder
    Collaborator

    Can you tell me more about the local web service? I'll see if I can repro.

  4. cfelstead commented on Jul 26, 2024

    @cfelstead
    Author

    When I experienced the issue I wanted to rule out it being my API somehow. So I’ve replaced it with the default .net 8 weather forecast api.

    This is a corporate machine so I’m not ruling out it being something to do with the setup there.

  5. self-assigned this
    on Jul 26, 2024
  6. garrytrinder commented on Jul 29, 2024

    @garrytrinder
    Collaborator

    I did some investigation today and can repro, I'll do some more digging tomorrow.

  7. garrytrinder commented on Jul 31, 2024

    @garrytrinder
    Collaborator

    @cfelstead I tested this scenario with a simple nodejs express API setup running on http://localhost:3000, here are my findings.

    index.js

    const express = require("express");
    const app = express();
    
    app.get("/", (req, res) => {
      res.json({ date: new Date() });
    });
    
    app.listen(3000, () => {
      console.log(`Server is running on port 3000`);
    });

    devproxyrc.json

    {
        "$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v0.19.1/rc.schema.json",
        "plugins": [
            {
                "name": "GenericRandomErrorPlugin",
                "enabled": true,
                "pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
                "configSection": "genericRandomErrorPlugin"
            }
        ],
        "genericRandomErrorPlugin": {
            "errorsFile": "errors.json"
        },
        "urlsToWatch": [
            "http://localhost:3000*"
        ]
    }

    errors.json

    {
        "$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v0.19.1/genericrandomerrorplugin.schema.json",
        "responses": [
            {
                "statusCode": 500,
                "body": "Internal Server Error",
                "headers": [
                    {
                        "name": "Content-Type",
                        "value": "application/json"
                    }
                ]
            }
        ]
    }

    Program.cs

    var client = new HttpClient();
    var response = await client.GetAsync("http://localhost:3000");
    
    Console.WriteLine(response.StatusCode);
    Console.WriteLine(await response.Content.ReadAsStringAsync());

    Tests

    Command Passed Through
    curl http://localhost:3000 ❌
    curl -x http://127.0.0.1:8000 http://localhost:3000 ✅
    dotnet run ✅ *
    Invoke-WebRequest -Uri http://localhost:3000 ✅*
    Invoke-WebRequest -Uri http://localhost:3000 -ProxyServer http://127.0.0.1:800 ❌
      • After starting Dev Proxy, you must create a new session for Proxy to be picked up, or toggle Use Proxy Server checkbox in Internet Options -> Connections -> LAN Settings... for existing sessions

    image

    • curl requires you to state the proxy you want to use in the command using -x option.
  8. garrytrinder commented on Jul 31, 2024

    @garrytrinder
    Collaborator

    Screenshot of web server, proxy and tests

    image

  9. cfelstead commented on Jul 31, 2024

    @cfelstead
    Author

    Thank you so much for you efforts @garrytrinder. I now have the application working as it should, however, only under certain conditions. Here are my notes. I am not ruling out some of these being specific to the work laptop in some way, however, hopefully they will help people in future.

    1. On a windows machine, Powershell overrules the curl command as an alias for invoke-webrequest. As a result, I have needed to call the exe built into windows directly by referencing "curl.exe" and not just "curl".

    2. HTTPS appears to be an issue. However, switching the API to load over HTTP works correctly.


    So, in order to get work I did the following.

    1. Inside devproxyrc.json make sure the urlsToWatch contains the API url as HTTP.
    "urlsToWatch": [
      "http://localhost:5256/*",
      .......
    ]
    1. Start devproxy in the windows terminal

    2. Start the project (debug mode or not using a HTTP profile)

    3. In a separate terminal running powershell, run the curl command as follows

    curl.exe -x http://127.0.0.1:8000 http://localhost:5256/people


    It is worth noting, I have not yet got it working without using curl.exe and specifying the proxy, for example, using a swagger UI. However, I am continuing to test and will report back with any news.

  10. cfelstead commented on Jul 31, 2024

    @cfelstead
    Author

    I can get Firefox to route through devproxy by setting the proxy server to 127.0.0.1:8000 and, in about:config changing the network.proxy.allow_hijacking_localhost setting to true.

    I cannot get Chrome or Edge to behave with the launch command

    msedge --proxy-bypass-list="<-loopback>" --proxy-server="127.0.0.1:8000"

  11. garrytrinder commented on Aug 5, 2024

    @garrytrinder
    Collaborator

    Thanks for the updated info @cfelstead

    I've been able to confirm that msedge --proxy-bypass-list="<-loopback>" --proxy-server="127.0.0.1:8000" works for me on Windows 11 and Edge Beta (128.0.2739.5) this morning.

    image

    I noticed however that Dev Proxy did not intercept requests unless I used the --proxy-server option, so we should update our docs to include that.

  12. cfelstead commented on Aug 5, 2024

    @cfelstead
    Author

    Interesting. I still can’t get it working.

    I did get the vs debugger working correctly (so dotnet run) as long as the proxy was running prior to the debugger launching.

  13. cfelstead commented on Aug 5, 2024

    @cfelstead
    Author

    I think I’m in a place where it is working enough for me to proceed. It i can provide more assistance, please let me know. Otherwise, I’m happy to close this.

  14. garrytrinder commented on Aug 5, 2024

    @garrytrinder
    Collaborator

    Thanks @cfelstead, I'll close this, but will work on updating the page to reference some of our findings in this issue. Thanks again for raising the issue, please let us know if there is anything we can help with.

  15. garrytrinder commented on Aug 5, 2024

    @garrytrinder
    Collaborator
  16. locked and limited conversation to collaborators on Jun 4, 2025
  17. converted this issue into a discussion #1224 on Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions