Solved: newman CLI returns 400 bad request when running test collection, but postman desktop app and CLI succeed

I created a simple POST request to https://postman-echo.com/post that got a 200 response in both Postman MacOS desktop app and with postman collection run. But newman run returned 400 Bad Request.

After more than an hour of debugging, I found it’s caused by disabling the host system header. Once I enabled that header, newman run succeeded. I’m not sure if this discrepancy in behavior between the Postman tools and newman is expected or a bug, but here’s the minimal repro and fix.

Here’s my exported collection with a single test.

{
	"info": {
		"_postman_id": "04475dd4-7885-4a87-82db-f74c52708f5a",
		"name": "test",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "44114086",
		"_collection_link": "https://dx-6430928.postman.co/workspace/DX's-Workspace~e5abf3c7-74fb-4f68-8a6f-6bfdd3d8c17b/collection/44114086-04475dd4-7885-4a87-82db-f74c52708f5a?action=share&source=collection_link&creator=44114086"
	},
	"item": [
		{
			"name": "postman-echo",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"pm.test(\"Status code is 200\", function () {",
							"    console.log(pm.request.headers);",
							"    pm.response.to.have.status(200);",
							"});"
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"protocolProfileBehavior": {
				"protocolVersion": "auto",
				"disableCookies": true,
				"disabledSystemHeaders": {
					"content-length": true,
					"host": true,
					"user-agent": true,
					"accept": true,
					"accept-encoding": true,
					"connection": true
				}
			},
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"DEAD\": \"BEEF\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://postman-echo.com/post",
					"protocol": "https",
					"host": [
						"postman-echo",
						"com"
					],
					"path": [
						"post"
					]
				}
			},
			"response": []
		}
	]
}

postman collection run succeeds.

$ postman collection run test.postman_collection.json --verbose
No authorization data found. Please use the `postman login` command.
Refer: https://learning.postman.com/docs/postman-cli/postman-cli-options/#postman-login

Running your collection...
postman

test

→ postman-echo

  POST https://postman-echo.com/post
  200 OK ★ 468 ms time ★ 181 B↑ 925 B↓ size ★ 4↑ 7↓ headers ★ 0 cookies
  ┌ ↑ raw ★ 22 B
  │ {
  │     "DEAD": "BEEF"
  │ }
  └
  ┌ ↓ application/json ★ text ★ json ★ utf8 ★ 607 B
  │ {
  │   "args": {},
  │   "data": {
  │     "DEAD": "BEEF"
  │   },
  │   "files": {},
  │   "form": {},
  │   "headers": {
  │     "host": "postman-echo.com",
  │     "x-request-start": "t1744806655.584",
  │     "connection": "close",
  │     "content-length": "22",
  │     "x-forwarded-proto": "https",
  │     "x-forwarded-port": "443",
  │     "x-amzn-trace-id": "Root=1-67ffa2ff-29812f605cadb24f479a4c19",
  │     "accept": "application/json",
  │     "content-type": "application/json",
  │     "cache-control": "no-cache",
  │     "postman-token": "207c8339-d80b-4d20-9124-03631d81063f"
  │   },
  │   "json": {
  │     "DEAD": "BEEF"
  │   },
  │   "url": "https://postman-echo.com/post"
  │ }
  └
  prepare   wait   dns-lookup   tcp-handshake   ssl-handshake   transfer-start   download   process   total
  2 ms      5 ms   124 ms       25 ms           56 ms           237 ms           18 ms      277 µs    470 ms

  ┌
  │ [
  │   { key: 'Accept', value: 'application/json' },
  │   { key: 'Content-Type', value: 'application/json', system: true },
  │   { key: 'Cache-Control', value: 'no-cache', system: true },
  │   { key: 'Postman-Token', value: '207c8339-d80b-4d20-9124-03631d81063f', system: true }
  │ ]
  └
  ✓  Status code is 200

┌─────────────────────────┬───────────────────────┬──────────────────────┐
│                         │              executed │               failed │
├─────────────────────────┼───────────────────────┼──────────────────────┤
│              iterations │                     1 │                    0 │
├─────────────────────────┼───────────────────────┼──────────────────────┤
│                requests │                     1 │                    0 │
├─────────────────────────┼───────────────────────┼──────────────────────┤
│            test-scripts │                     1 │                    0 │
├─────────────────────────┼───────────────────────┼──────────────────────┤
│      prerequest-scripts │                     0 │                    0 │
├─────────────────────────┼───────────────────────┼──────────────────────┤
│              assertions │                     1 │                    0 │
├─────────────────────────┴───────────────────────┴──────────────────────┤
│ total run duration: 505 ms                                             │
├────────────────────────────────────────────────────────────────────────┤
│ total data received: 607 B (approx)                                    │
├────────────────────────────────────────────────────────────────────────┤
│ average response time: 468 ms [min: 468 ms, max: 468 ms, s.d.: 0 µs]   │
├────────────────────────────────────────────────────────────────────────┤
│ average DNS lookup time: 124 ms [min: 124 ms, max: 124 ms, s.d.: 0 µs] │
├────────────────────────────────────────────────────────────────────────┤
│ average first byte time: 237 ms [min: 237 ms, max: 237 ms, s.d.: 0 µs] │
└────────────────────────────────────────────────────────────────────────┘
Postman api key is required for publishing run details to Postman cloud.
Please specify it by using the `postman login` command

But newman run fails with 400 Bad Request.

$ newman run test.postman_collection.json --verbose
newman

test

→ postman-echo
  POST https://postman-echo.com/post
  400 Bad Request ★ 164ms time ★ 181B↑ 272B↓ size ★ 4↑ 5↓ headers ★ 0 cookies
  ┌ ↑ raw ★ 22B
  │ {
  │     "DEAD": "BEEF"
  │ }
  └
  ┌ ↓ text/html ★ text ★ html ★ utf8 ★ 122B
  │ <html>
  │ <head><title>400 Bad Request</title></head>
  │ <body>
  │ <center><h1>400 Bad Request</h1></center>
  │ </body>
  │ </html>
  └
  prepare   wait   dns-lookup   tcp-handshake   ssl-handshake   transfer-start   download   process   total
  1ms       11ms   2ms          26ms            96ms            19ms             6ms        176µs     165ms

  ┌
  │ [
  │   { key: 'Accept', value: 'application/json' },
  │   { key: 'Content-Type', value: 'application/json', system: true },
  │   { key: 'Cache-Control', value: 'no-cache', system: true },
  │   { key: 'Postman-Token', value: 'dad6eda7-e8ee-4b39-938c-0cb8f27a541c', system: true }
  │ ]
  └
  1. Status code is 200

┌─────────────────────────┬────────────────────┬───────────────────┐
│                         │           executed │            failed │
├─────────────────────────┼────────────────────┼───────────────────┤
│              iterations │                  1 │                 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│                requests │                  1 │                 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│            test-scripts │                  1 │                 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│      prerequest-scripts │                  0 │                 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│              assertions │                  1 │                 1 │
├─────────────────────────┴────────────────────┴───────────────────┤
│ total run duration: 212ms                                        │
├──────────────────────────────────────────────────────────────────┤
│ total data received: 122B (approx)                               │
├──────────────────────────────────────────────────────────────────┤
│ average response time: 164ms [min: 164ms, max: 164ms, s.d.: 0µs] │
├──────────────────────────────────────────────────────────────────┤
│ average DNS lookup time: 2ms [min: 2ms, max: 2ms, s.d.: 0µs]     │
├──────────────────────────────────────────────────────────────────┤
│ average first byte time: 19ms [min: 19ms, max: 19ms, s.d.: 0µs]  │
└──────────────────────────────────────────────────────────────────┘

  #  failure                                   detail

 1.  AssertionError                            Status code is 200
                                               expected response to have status code 200 but got 400
                                               at assertion:0 in test-script
                                               inside "postman-echo"

Once I changed

				"disabledSystemHeaders": {
					"content-length": true,
					"host": true,

to

				"disabledSystemHeaders": {
					"content-length": true,
					"host": false,

or just removed the "host" entry newman worked.

$ newman run test.postman_collection.json --verbose
newman

test

→ postman-echo
  POST https://postman-echo.com/post
  200 OK ★ 298ms time ★ 205B↑ 869B↓ size ★ 5↑ 7↓ headers ★ 0 cookies
  ┌ ↑ raw ★ 22B
  │ {
  │     "DEAD": "BEEF"
  │ }
  └
  ┌ ↓ application/json ★ text ★ json ★ utf8 ★ 537B
  │ {
  │   "args": {},
  │   "data": {},
  │   "files": {},
  │   "form": {},
  │   "headers": {
  │     "host": "postman-echo.com",
  │     "x-request-start": "t1744806797.833",
  │     "connection": "close",
  │     "x-forwarded-proto": "https",
  │     "x-forwarded-port": "443",
  │     "x-amzn-trace-id": "Root=1-67ffa38d-3a59066727c96cd9200aae2d",
  │     "accept": "application/json",
  │     "content-type": "application/json",
  │     "cache-control": "no-cache",
  │     "postman-token": "a461906c-e93d-4602-9db8-d7e7707d964c"
  │   },
  │   "json": null,
  │   "url": "https://postman-echo.com/post"
  │ }
  └
  prepare   wait   dns-lookup   tcp-handshake   ssl-handshake   transfer-start   download   process   total
  1ms       11ms   126ms        24ms            99ms            26ms             10ms       244µs     299ms

  ┌
  │ [
  │   { key: 'Accept', value: 'application/json' },
  │   { key: 'Content-Type', value: 'application/json', system: true },
  │   { key: 'Cache-Control', value: 'no-cache', system: true },
  │   { key: 'Postman-Token', value: 'a461906c-e93d-4602-9db8-d7e7707d964c', system: true },
  │   { key: 'Host', value: 'postman-echo.com', system: true }
  │ ]
  └
  ✓  Status code is 200

┌─────────────────────────┬─────────────────────┬────────────────────┐
│                         │            executed │             failed │
├─────────────────────────┼─────────────────────┼────────────────────┤
│              iterations │                   1 │                  0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│                requests │                   1 │                  0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│            test-scripts │                   1 │                  0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│      prerequest-scripts │                   0 │                  0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│              assertions │                   1 │                  0 │
├─────────────────────────┴─────────────────────┴────────────────────┤
│ total run duration: 344ms                                          │
├────────────────────────────────────────────────────────────────────┤
│ total data received: 537B (approx)                                 │
├────────────────────────────────────────────────────────────────────┤
│ average response time: 298ms [min: 298ms, max: 298ms, s.d.: 0µs]   │
├────────────────────────────────────────────────────────────────────┤
│ average DNS lookup time: 126ms [min: 126ms, max: 126ms, s.d.: 0µs] │
├────────────────────────────────────────────────────────────────────┤
│ average first byte time: 26ms [min: 26ms, max: 26ms, s.d.: 0µs]    │
└────────────────────────────────────────────────────────────────────┘

Postman MacOS desktop app version info
Version 11.41.1-250415-1220
UI Version: 11.41.1-ui-250415-1220
Desktop Platform Version: 11.40.5 (11.40.5)

postman CLI version 1.13.1
newman CLI version 6.2.1

2 Likes