Running mock server on localhost

Hi,

Is there a way to make a mock server run locally on my machine? The app I’m testing expects the API to be on localhost:xxxx and I can’t change that.

Thanks,
Mike

Currently Postman mocks servers only run in the cloud, but you can easily control what localhost means on your machine with your local DNS, changing localhost to map to whatever address you need - here are some instructions on working with local DNS on windows & mac - https://bowerwebsolutions.com/how-to-edit-your-local-host-file-for-testing-web-sites/

Ok, thanks. I wish they could run locally for security purposes.

@kinlane maybe an easier approach would be to use something like netcat or ssh to forward connections? Sounds like off-premise calls are a security concern in this case though.

Though this may not apply in this case, for posterity, I thought I’d mention that mock servers can run behind a protected endpoint using a Postman API key. See Editing Mock Servers in the Learning Center.

With the release of V12, Local Mocks can now be used in the platform. :heart:

You can now create a mock server that simulates a real API server in your local Git repository, where you’re making API changes. This enables you to quickly set up your service locally by mocking the APIs it depends on.

You can create a local mock server from a template to define logic yourself or use Agent Mode to quickly get started.

You can also use the Postman CLI to validate your collection’s tests against a mock server or start a mock server in your CI/CD pipeline. Once your local mock server is running, you can send requests to it just like a real API.

To learn more, see Simulate your API locally using a Git-backed mock server.