How to set proxy when we run collection using command line

I am using Postman to test and Automate our API and we are facing proxy issues while running it via Command line.

To test our Api we are setting proxy in our Postman app, but when we run it through command line its failing since proxy is not passed.

Could you please let me know how we can set proxy when we run collection from command line using Newman.

Hi @ashutosh315ec,

Welcome to the postman community! :clap:

Since you are running your collections via the newman command line, the only way you can run it via the proxy is to set up the proxy at the system level (OS), as noted in the postman doc below.

https://learning.postman.com/docs/sending-requests/capturing-request-data/proxy/#using-system-proxy

Since I am not sure what OS you are running these collections on, I wouldnโ€™t which way to exactly do it.

Here is a link on how to set up a proxy in Windows:
https://www.howtogeek.com/tips/how-to-set-your-proxy-settings-in-windows-8.1/

macOS:

Linux:
https://www.cyberciti.biz/faq/linux-unix-set-proxy-environment-variable/

Linux will vary depending on your OS, but the process should be relatively similar.

Hope this helps!
Orest

1 Like

I read at github Forum that people use in command line: HTTP_PROXY=โ€˜http://login:password@proxy:80/โ€™ newman run postman_collection.json

but it doesnโ€™t work for me. the response is HTTP_PROXY is a wrong command

my idea now was to set HTTP_PROXY as env variable. then i export the file and added the command โ€œ-e myenv.jsonโ€ with key: HTTP_PROXY and value http://login:password@proxy:80/

but still timeout because of proxy issue

Hello eveyone

I need to put two proxies in the newman run CLI. I have a request that needs the proxy and another request that is localhost that doesnโ€™t need it. I need the proxy not to apply for the localhost

set HTTP_PROXY=example.com NO_PROXY=localhost && newman run collection.json