One of my colleague had some issue while running the JMeter scripts behind the VPN or proxy. I proposed four solutions. I would like to share those four solutions here, two of them within the JMeter UI itself, another one we can do along with launching JMeter, and the final one is a static configuration within the system.properties file that available within JMeter/bin. We will discuss below more on different solutions.
Solution 1: Configure the Proxy Server into each HTTP Request
In the HTTP Request, we can find out the Proxy Server section at the Advanced tab of the HTTP Request element. There we can add the proxy server name or IP address, port number, username, and password. In some cases, username and password are optional. Below is the screenshot details,

Solution 2: Configure the Proxy Server into HTTP Request Defaults
Suppose if we have 50 or more HTTP Requests, then it will be difficult to configure the Proxy Server details in each HTTPT Request that we discussed in Solution 1. And also, in future your proxy settings changed, we may have to change those 50 and more requests. So the idea is to configure the Proxy Server into HTTP Request Defaults. In this case, we will not input anything into the HTTP Requests, just open HTTP Request Defaults, find out the Proxy Server at the Advanced tab, and configure the details. You can add HTTP Request Defaults under Test Plan and at the Thread Group level like a global declaration. Below is the screenshot details,

Solution 3: Launch JMeter from the command line with the following parameters
-H
[proxy server hostname or IP address]
-P
[proxy server port]
-N
[nonproxy hosts] (e.g. *.apache.org|localhost)
-u
[username for proxy authentication – if required]
-a
[password for proxy authentication – if required]
Following are some examples in the Windows system:
jmeter -H [proxyAddress] -P [portNumber]
Or you can use the IP instead of the Server name
jmeter -H [IPAddress] -P [portNumber]
If your Proxy Server required a username and password, use the command below
jmeter -H [proxyAddress] -P [portNumber] -u [username] -a [password]
If a non-proxy host list is provided, use this command
jmeter -H [proxyAddress] -P [portNumber] -u [username] -a [password] -N [proxyAddress]
In the above method, no need to worry about the proxy server configuration at the JMeter UI level.
Solution 4: Setup the proxy properties into the system properties file
Open the system.properties in edit mode, this file is located under \apache-jmeter-5.1.1\bin directory (I am using JMeter 5.1.1). Add the following properties to the end of the file,
http.proxyHost
http.proxyPort
https.proxyHost
https.proxyPort
For example:
http.proxyHost=localhost
http.proxyPort=8887
https.proxyHost=localhost
https.proxyPort=8887
Suppose if a non-proxy host list is provided, then JMeter sets the following system properties:
http.nonProxyHosts
https.nonProxyHosts
We can use one of the above solutions to run the JMeter script behind the VPN or proxy. We can ignore the first method if you have more HTTP Requests to execute. In some situations, we may need to work on the scripts without VPN or proxy, in that case, we can go ahead with solution 2 (need to disable HTTP Request Defaults component) or solution 3.
Please try to utilize any of the above solutions if you have a situation of running JMeter scripts behind the VPN or proxy.
make it perfect!
Leave a Reply