Listen on all ips #624

Closed
opened 2025-12-29 08:31:22 +01:00 by adam · 5 comments
Owner

Originally created by @cocoon on GitHub (Aug 9, 2024).

Originally assigned to: @StefH on GitHub.

I ask this as question, maybe I missed something obvious.

When I want to listen to all public IPs I thought I could use http://0.0.0.0 as URL, but it was not working.
So I had to get all my current IPs and add them as List.

And when I check this line of code:

https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Owin/AspNetCoreSelfHost.NETStandard.cs#L79

it looks like it should use "ListenAnyIP" but instead it is listed in "ListenLocalhost"?

Originally created by @cocoon on GitHub (Aug 9, 2024). Originally assigned to: @StefH on GitHub. I ask this as question, maybe I missed something obvious. When I want to listen to all public IPs I thought I could use http://0.0.0.0 as URL, but it was not working. So I had to get all my current IPs and add them as List. And when I check this line of code: https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Owin/AspNetCoreSelfHost.NETStandard.cs#L79 it looks like it should use "ListenAnyIP" but instead it is listed in "ListenLocalhost"?
adam added the bug label 2025-12-29 08:31:22 +01:00
adam closed this issue 2025-12-29 08:31:22 +01:00
Author
Owner

@StefH commented on GitHub (Aug 9, 2024):

I need to double check that.

BTW what .NET version are you using?

@StefH commented on GitHub (Aug 9, 2024): I need to double check that. BTW what .NET version are you using?
Author
Owner

@cocoon commented on GitHub (Aug 9, 2024):

I usually use .net 8 now.

@cocoon commented on GitHub (Aug 9, 2024): I usually use .net 8 now.
Author
Owner

@cocoon commented on GitHub (Aug 12, 2024):

I tried it and moved the host check for 0.0.0.0 at top and return it as ListenAnyIP and it works:

if (urlDetail is { Port: > 0, Host: "0.0.0.0" })
 {
     kestrelOptions.ListenAnyIP(urlDetail.Port, configure);
     return;
 }
var Settings = new WireMock.Settings.WireMockServerSettings
{
    Urls = new string[] { "http://0.0.0.0:80" },
    AllowPartialMapping = true,
    StartAdminInterface = true,
};

var server = WireMockServer.Start(Settings);

WireMock NET-0 0 0 0

@cocoon commented on GitHub (Aug 12, 2024): I tried it and moved the host check for 0.0.0.0 at top and return it as ListenAnyIP and it works: ``` if (urlDetail is { Port: > 0, Host: "0.0.0.0" }) { kestrelOptions.ListenAnyIP(urlDetail.Port, configure); return; } ``` ``` var Settings = new WireMock.Settings.WireMockServerSettings { Urls = new string[] { "http://0.0.0.0:80" }, AllowPartialMapping = true, StartAdminInterface = true, }; var server = WireMockServer.Start(Settings); ``` ![WireMock NET-0 0 0 0](https://github.com/user-attachments/assets/3aba5700-b473-4936-81cb-5d469e3ec393)
Author
Owner

@StefH commented on GitHub (Aug 13, 2024):

Looks good.

Can you make a PR and if possible add/update a unit test?

@StefH commented on GitHub (Aug 13, 2024): Looks good. Can you make a PR and if possible add/update a unit test?
Author
Owner

@cocoon commented on GitHub (Sep 4, 2024):

PR created and tried to add a test.

@cocoon commented on GitHub (Sep 4, 2024): PR created and tried to add a test.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#624