# How do I set up a Proxy with the Java version of Gatling

**URL:** <https://community.gatling.io/t/how-do-i-set-up-a-proxy-with-the-java-version-of-gatling/9719>\
**Category:** Gatling (Open-Source)\
**Created:** [July 14, 2025, 8:35pm UTC](https://community.gatling.io/t/how-do-i-set-up-a-proxy-with-the-java-version-of-gatling/9719 "2025-07-14T20:35:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeslieM](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/lesliem/32/1659_2.png) [@LeslieM](https://community.gatling.io/u/LeslieM)\
**Post date:** [July 14, 2025, 8:35pm UTC](https://community.gatling.io/t/how-do-i-set-up-a-proxy-with-the-java-version-of-gatling/9719/1 "2025-07-14T20:35:07Z")

</div>

I am new to Gatling. Cannot figure out how to set up the HttpProtocolBuilder in Java to use a proxy. Can someone point me at an example?

\*\*Gatling version 3.14.3 \*\*:  
**Gatling flavor** : [X] java kotlin scala javascript typescript  
**Gatling build tool** : [X] maven gradle sbt bundle npm

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [July 14, 2025, 8:37pm UTC](https://community.gatling.io/t/how-do-i-set-up-a-proxy-with-the-java-version-of-gatling/9719/2 "2025-07-14T20:37:19Z")

</div>

Please explain exactly what you’re doing and the problem you’re facing.

---

<div class="post-metadata">

**Author:** ![LeslieM](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/lesliem/32/1659_2.png) [@LeslieM](https://community.gatling.io/u/LeslieM)\
**Post date:** [July 14, 2025, 8:51pm UTC](https://community.gatling.io/t/how-do-i-set-up-a-proxy-with-the-java-version-of-gatling/9719/3 "2025-07-14T20:51:19Z")

</div>

I am trying to run the demo, however the work machine I am using requires a proxy to reach the internet. When I run the demo script I get j.n.c.ClosedChannelException

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [July 15, 2025, 6:39am UTC](https://community.gatling.io/t/how-do-i-set-up-a-proxy-with-the-java-version-of-gatling/9719/4 "2025-07-15T06:39:20Z")

</div>

OK, so now we have the problem you’re facing but we’re still lacking what you’re doing exactly 😀

Please share your protocol configuration.

---

<div class="post-metadata">

**Author:** ![LeslieM](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/lesliem/32/1659_2.png) [@LeslieM](https://community.gatling.io/u/LeslieM)\
**Post date:** [July 15, 2025, 1:54pm UTC](https://community.gatling.io/t/how-do-i-set-up-a-proxy-with-the-java-version-of-gatling/9719/5 "2025-07-15T13:54:57Z")

</div>

Thanks for looking into this!

I’d also be OK with using the scala version to get started. All of the documentation I found online for Gatling regarding proxy seems to be for the Scala DSL.

However, I don’t see any samples for Scala in the gatling-charts-highcharts-bundle-3.14.3 zip. Is there a different scala bundle I need to download to try that out?

Also, I started looking at a tutorial on Gatling Scala that used version 3.8. Is there a download location to obtain older versions, if I want to use the exact version used in the training material?

My configuration is the generic one that comes within the zip file BasicSimulation.java. Based on my research I tried to add a proxy but was unable to get it to compile.

> // Define HTTP configuration  
> private static final HttpProtocolBuilder httpProtocol = http.baseUrl(“[https://api-ecomm.gatling.io](https://api-ecomm.gatling.io)”)  
> .acceptHeader(“application/json”)  
> .userAgentHeader( “Mozilla/5.0 …”)  
> // .proxy(httpProxy(“10.1.32.228”, 8080)); // httpProxy symbol not found  
> .proxy(new Proxy(“10.1.32.228”, 8080, 8080, null)); // also does not compile

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [July 15, 2025, 2:13pm UTC](https://community.gatling.io/t/how-do-i-set-up-a-proxy-with-the-java-version-of-gatling/9719/6 "2025-07-15T14:13:59Z")

</div>

Hi,

> All of the documentation I found online for Gatling regarding proxy seems to be for the Scala DSL.

Which documentation are you searching?  
Our official documentation has samples for Java, JavaScript, Kotlin and Scala.  
cf [Gatling HTTP protocol reference - protocol configuration](https://docs.gatling.io/reference/script/http/protocol/#proxy)

> However, I don’t see any samples for Scala in the gatling-charts-highcharts-bundle-3.14.3 zip. Is there a different scala bundle I need to download to try that out?

No, there isn’t. We now only provide a beginner-friendly standalone bundle for Java. Scala is not beginner friendly. If you really want to go with Scala (which we don’t recommend unless you are a Scala developper), you can check our different demo projects for the different build tools, eg [Maven Plugin for Gatling and Gatling Enterprise](https://docs.gatling.io/integrations/build-tools/maven-plugin/).

> Also, I started looking at a tutorial on Gatling Scala

You seem to be trying to use outdated material from a third-party source.  
I recommend you check our official tutorials: [How to get started with Gatling](https://docs.gatling.io/tutorials/)

> that used version 3.8.

Sorry, but we can’t help with outdated versions. 3.8 was from 3 years ago.  
Please use the latest Gatling 3.14.3.

> Based on my research I tried to add a proxy but was unable to get it to compile.

You have the correct syntax on our documentation page I linked above (for Gatling 3.13.4).

Regards

---

<div class="post-metadata">

**Author:** ![LeslieM](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/lesliem/32/1659_2.png) [@LeslieM](https://community.gatling.io/u/LeslieM)\
**Post date:** [July 16, 2025, 6:03am UTC](https://community.gatling.io/t/how-do-i-set-up-a-proxy-with-the-java-version-of-gatling/9719/7 "2025-07-16T06:03:25Z")

</div>

Thanks for your support and the additional context and guidance. This code worked 🙂

> private static final HttpProtocolBuilder httpProtocol = http.baseUrl(“[https://api-ecomm.gatling.io](https://api-ecomm.gatling.io)”)  
> .acceptHeader(“application/json”)  
> .userAgentHeader(  
> “Mozilla…”)  
> .proxy( Proxy(“10.1.32.228”, 8080));

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/b/b148e0742de35c6280726cabf3ecd3de2d320f63.png) [@system](https://community.gatling.io/u/system)\
**Post date:** [August 15, 2025, 6:04am UTC](https://community.gatling.io/t/how-do-i-set-up-a-proxy-with-the-java-version-of-gatling/9719/8 "2025-08-15T06:04:13Z")

</div>

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