# Collection runs fine in Postman but fails with errors in Newman

**URL:** <https://community.postman.com/t/collection-runs-fine-in-postman-but-fails-with-errors-in-newman/36902>\
**Category:** Help Hub\
**Tags:** newman-project, tests, collections\
**Created:** [July 6, 2022, 7:54am UTC](https://community.postman.com/t/collection-runs-fine-in-postman-but-fails-with-errors-in-newman/36902 "2022-07-06T07:54:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![katamba](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/katamba/32/12413_2.png) [@katamba](https://community.postman.com/u/katamba)\
**Post date:** [July 6, 2022, 7:54am UTC](https://community.postman.com/t/collection-runs-fine-in-postman-but-fails-with-errors-in-newman/36902/1 "2022-07-06T07:54:24Z")

</div>

> **Archived topic — this may be out of date.**  
> Newman has been replaced by the **[Postman CLI](https://learning.postman.com/docs/postman-cli/postman-cli-overview/)**, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.  
> Working with an AI coding agent? The [Postman plugin](https://github.com/postmanlabs/postman-plugin) lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.  
> 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).

Collection runs fine in Postman but fails with errors in Newman

When I run a collection in Postman, it runs successfully and all the tests are passing. But when I run it in newman with the command: `newman run [collection_link]`  
, all tests fail with one common error, which is: `[401 Unauthorized...]`

I found the problem while trying to run collections using newman.

I have already tried to look through the community forum for answers, but I haven’t yet come across a helpful answer. I also found that @sankarasai18 reported a similar issue [here](https://community.postman.com/t/postman-collection-runs-fine-on-postman-but-not-on-newman/24002) but I couldn’t find any responses to that.  
Anyone?

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [July 6, 2022, 11:12am UTC](https://community.postman.com/t/collection-runs-fine-in-postman-but-fails-with-errors-in-newman/36902/2 "2022-07-06T11:12:51Z")

</div>

Hi @katamba

I would usually associate 401 Unauthorized with the user being restricted.

Are you passing any auth tokens in your collection?

---

<div class="post-metadata">

**Author:** ![katamba](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/katamba/32/12413_2.png) [@katamba](https://community.postman.com/u/katamba)\
**Post date:** [July 6, 2022, 12:07pm UTC](https://community.postman.com/t/collection-runs-fine-in-postman-but-fails-with-errors-in-newman/36902/3 "2022-07-06T12:07:17Z")

</div>

Yes, there’s a Bearer token, which I stored inside a collection variable. What am failing to understand is why it’s restricting me in newman, and yet it runs successfully in Postman without any issues.

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [July 6, 2022, 12:43pm UTC](https://community.postman.com/t/collection-runs-fine-in-postman-but-fails-with-errors-in-newman/36902/4 "2022-07-06T12:43:12Z")

</div>

Are you sure that the token hasn’t expired or something like that?

---

<div class="post-metadata">

**Author:** ![katamba](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/katamba/32/12413_2.png) [@katamba](https://community.postman.com/u/katamba)\
**Post date:** [July 6, 2022, 12:48pm UTC](https://community.postman.com/t/collection-runs-fine-in-postman-but-fails-with-errors-in-newman/36902/5 "2022-07-06T12:48:38Z")

</div>

Yes sir, I’ve actually regenerated the token, but still, the issue persists.

---

<div class="post-metadata">

**Author:** ![satellite-geoscient3](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@satellite-geoscient3](https://community.postman.com/u/satellite-geoscient3)\
**Post date:** [May 8, 2023, 7:41am UTC](https://community.postman.com/t/collection-runs-fine-in-postman-but-fails-with-errors-in-newman/36902/6 "2023-05-08T07:41:08Z")

</div>

Hi,  
Is there any solution about this issue?

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [May 9, 2023, 11:35am UTC](https://community.postman.com/t/collection-runs-fine-in-postman-but-fails-with-errors-in-newman/36902/7 "2023-05-09T11:35:19Z")

</div>

@satellite-geoscient3

I would recommend raising your own topic.

Include screenshots and code snippets on how you are currently generating and setting the token. Collection variable, Environment, etc. (Redacted as appropriate).

Confirm its working ok in Postman first.

This functionality does work in Newman, so it will be related to how the token is being generated and saved.

---

<div class="post-metadata">

**Author:** ![satellite-speciali11](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@satellite-speciali11](https://community.postman.com/u/satellite-speciali11)\
**Post date:** [August 2, 2023, 2:51am UTC](https://community.postman.com/t/collection-runs-fine-in-postman-but-fails-with-errors-in-newman/36902/8 "2023-08-02T02:51:39Z")

</div>

I Found a solution it works with me… i duplicated my collection and renamed it with different name, then i deleted the old collection from postman and it works
