WireMock not working when attempting to access from anything other than localhost. #55

Closed
opened 2025-12-29 14:21:50 +01:00 by adam · 4 comments
Owner

Originally created by @josh-curtis90 on GitHub (Jan 17, 2018).

Hi there,

I've run into an issue when trying to access a wiremock mock instance running on 0.0.0.1 FROM an application running on 0.0.0.2 using http://0.0.0.1/things/other-things.

Can be replicated much simpler by trying to access a wiremock standalone instance on your local machine on your IP rather than localhost.

I'm getting a 400 Invalid Hostname.

Tried this using the java version of wiremock standalone also and it working fine.

Any ideas?

Cheers,

Josh

Originally created by @josh-curtis90 on GitHub (Jan 17, 2018). Hi there, I've run into an issue when trying to access a wiremock mock instance running on 0.0.0.1 FROM an application running on 0.0.0.2 using http://0.0.0.1/things/other-things. Can be replicated much simpler by trying to access a wiremock standalone instance on your local machine on your IP rather than localhost. I'm getting a 400 Invalid Hostname. Tried this using the java version of wiremock standalone also and it working fine. Any ideas? Cheers, Josh
adam closed this issue 2025-12-29 14:21:50 +01:00
Author
Owner

@josh-curtis90 commented on GitHub (Jan 17, 2018):

Just seen https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Server/FluentMockServer.cs#L156.

I'm using a dynamic ports which is hardcoding the URL to be "localhost" + port.

@josh-curtis90 commented on GitHub (Jan 17, 2018): Just seen https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Server/FluentMockServer.cs#L156. I'm using a dynamic ports which is hardcoding the URL to be "localhost" + port.
Author
Owner

@josh-curtis90 commented on GitHub (Jan 17, 2018):

Whoops didn't mean to close.

I can get around this by using the PortUtil; in my calling code, so I guess its a non-issue unless you intended it to work differently?

@josh-curtis90 commented on GitHub (Jan 17, 2018): Whoops didn't mean to close. I can get around this by using the PortUtil; in my calling code, so I guess its a non-issue unless you intended it to work differently?
Author
Owner

@StefH commented on GitHub (Jan 17, 2018):

You could use 'http://*:80' for an url? Which makes WireMock listen on all ip?

Or do you want to start WireMock with dynamic ports and listen to http://* instead of http://localhost ?

@StefH commented on GitHub (Jan 17, 2018): You could use 'http://*:80' for an url? Which makes WireMock listen on all ip? Or do you want to start WireMock with dynamic ports and listen to `http://*` instead of `http://localhost` ?
Author
Owner

@josh-curtis90 commented on GitHub (Jan 18, 2018):

Yeah basically the second one. I just used PortUtil to get an available port and constructed a Url out of that port and a the host of the wiremock servers IP. Perhaps http://*:port would be more appropriate in the FluentMockServer.

Will close though as I don't think using PortUtil directly is a "bad" thing.

@josh-curtis90 commented on GitHub (Jan 18, 2018): Yeah basically the second one. I just used PortUtil to get an available port and constructed a Url out of that port and a the host of the wiremock servers IP. Perhaps http://*:port would be more appropriate in the FluentMockServer. Will close though as I don't think using PortUtil directly is a "bad" thing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#55