# Running mock server on localhost

**URL:** <https://community.postman.com/t/running-mock-server-on-localhost/12017>\
**Category:** Help Hub\
**Tags:** ci-cd, development, mock-server, local\
**Created:** [April 17, 2020, 1:07pm UTC](https://community.postman.com/t/running-mock-server-on-localhost/12017 "2020-04-17T13:07:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdemers](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mdemers](https://community.postman.com/u/mdemers)\
**Post date:** [April 17, 2020, 1:07pm UTC](https://community.postman.com/t/running-mock-server-on-localhost/12017/1 "2020-04-17T13:07:29Z")

</div>

> **Archived topic — some details may be out of date.**  
> Mock servers built from saved collection examples are still supported. Postman now also has **code-based mocks** : JavaScript request handlers plus a `config.yaml`, stored as files in your Git repository, which you can run locally or deploy. Create one in the app, or use the Postman CLI to generate one from an OpenAPI spec, collection or dataset (`postman mock generate`) and run it (`postman mock run`). See [About mocks](https://learning.postman.com/docs/design-apis/mock-apis/mocks/overview) and [Create a mock](https://learning.postman.com/docs/design-apis/mock-apis/mocks/create-a-mock).  
> Working with an AI coding agent? The [Postman plugin](https://github.com/postmanlabs/postman-plugin) can build and run mocks for you.  
> For current help, see the [Postman docs](https://learning.postman.com/docs/), try the free [Postman tools](https://www.postman.com/tools) (no account needed), or join us on [Discord](https://discord.gg/58aNNsRBGR).

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

---

<div class="post-metadata">

**Author:** ![kinlane](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kinlane/32/347_2.png) [@kinlane](https://community.postman.com/u/kinlane)\
**Post date:** [April 17, 2020, 3:59pm UTC](https://community.postman.com/t/running-mock-server-on-localhost/12017/2 "2020-04-17T15:59:21Z")

</div>

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/](https://bowerwebsolutions.com/how-to-edit-your-local-host-file-for-testing-web-sites/)

---

<div class="post-metadata">

**Author:** ![mdemers](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mdemers](https://community.postman.com/u/mdemers)\
**Post date:** [April 17, 2020, 4:25pm UTC](https://community.postman.com/t/running-mock-server-on-localhost/12017/3 "2020-04-17T16:25:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hod.greeley](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/hod.greeley/32/3815_2.png) [@hod.greeley](https://community.postman.com/u/hod.greeley)\
**Post date:** [April 17, 2020, 6:42pm UTC](https://community.postman.com/t/running-mock-server-on-localhost/12017/4 "2020-04-17T18:42:04Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![kevin.swiber](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kevin.swiber/32/3820_2.png) [@kevin.swiber](https://community.postman.com/u/kevin.swiber)\
**Post date:** [April 17, 2020, 9:57pm UTC](https://community.postman.com/t/running-mock-server-on-localhost/12017/5 "2020-04-17T21:57:36Z")

</div>

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](https://learning.postman.com/docs/postman/mock-servers/setting-up-mock/#editing-mock-servers) in the Learning Center.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/7/0/704368c8f02043a8aa3f125687aa0c6b0340e20a.jpeg)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [March 3, 2026, 11:23am UTC](https://community.postman.com/t/running-mock-server-on-localhost/12017/6 "2026-03-03T11:23:44Z")

</div>

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

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.

 ![Screenshot 2026-03-03 at 11.20.21](https://us1.discourse-cdn.com/getpostman/original/3X/0/2/0205717608f50f3748ef80ba38a65714d45a4490.png)

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

 ![Screenshot 2026-03-03 at 11.20.54](https://us1.discourse-cdn.com/getpostman/original/3X/9/f/9f1cb29225f9e5fa6119e349c3b47ebaae3e5be1.png)

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.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/5/a5540ac2f917a041dca98757c594dd74367885d3.png)

To learn more, see [Simulate your API locally using a Git-backed mock server](https://learning.postman.com/docs/design-apis/mock-apis/local-mock-servers/).
