Skip ECONNREFUSED in a collection and run other requests

I have 40+ request in a collection. When the first request gets connected refused error ECONNREFUSED, postman stops executing further. How do I overcome this.

Hi @aviation-astronaut12. Welcome to the Postman Community.

This error often indicates that you’re making a request to an invalid URL or that the client could not establish a connection to the server. A collection run is a sequential workflow. Hence, a request to an invalid endpoint breaks this flow. Ensure that the request is being made to an actual API endpoint that can return an error of something goes wrong.

All those URL are valid, these 40+ tests are running in 10 different servers. There are times when server undergo patching some endpoint will throw CONNECTION REFUSED. So I am looking for a way to skip these endpoint which are down and proceed with collection run

There’s a way you can work around this using pre-request scripts.

Test and pre-request scripts authored at the collection(and not request) level are run against every request in that collection when you use the collection runner.

Postman scripts give you access to the current request URL and also allow you to make an HTTP request from within a pre-request or test script.

In the pre-request script of your collection, you can make a “ping” to the current request URL, and skip the execution of that request in the runner if it returns an error as shown in the below screenshot.

This way, even if the server is currently unable to process the request, the collection runner simply skips the execution of that request and moves on to the next one. Then it does the same till the workflow is done running. You can check this example in this sample demo I created.

The first test request “Test1” has an invalid URL, while the second one is correct. Only the first gets executed.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.