# Cannot apply plugin with the "plugin DSL" when running behind an authenticated proxy

**URL:** <https://discuss.gradle.org/t/cannot-apply-plugin-with-the-plugin-dsl-when-running-behind-an-authenticated-proxy/2202>\
**Category:** Old Forum Archive\
**Created:** [January 19, 2015, 1:36pm UTC](https://discuss.gradle.org/t/cannot-apply-plugin-with-the-plugin-dsl-when-running-behind-an-authenticated-proxy/2202 "2015-01-19T13:36:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rzabini](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@rzabini](https://discuss.gradle.org/u/rzabini)\
**Post date:** [January 19, 2015, 1:36pm UTC](https://discuss.gradle.org/t/cannot-apply-plugin-with-the-plugin-dsl-when-running-behind-an-authenticated-proxy/2202/1 "2015-01-19T13:36:00Z")

</div>

Running gradle behind an authenticated proxy, I am able to apply plugins in the standard way (apply plugin: + buildscript classpath dependency). I provide the proxy settings (host, username and password) through gradle.properties, or directly from the command line (-Dhttps.proxyUser=… etc).

However, the same procedure does not work when applying a plugin through the plugins DSL.

14:09:53.381 [DEBUG] [org.apache.http.impl.client.SystemDefaultHttpClient] CONNECT refused by proxy: HTTP/1.0 407 Proxy Authentication Required … 14:09:53.474 [ERROR] [org.gradle.BuildExceptionReporter] Error resolving plugin [id: ‘com.jfrog.bintray’, version: ‘1.0’] 14:09:53.490 [ERROR] [org.gradle.BuildExceptionReporter] \> The response from [https://plugins.gradle.org/api/gradle/2.2.1/plugin/use/com.jfrog.bintray/1.0](https://plugins.gradle.org/api/gradle/2.2.1/plugin/use/com.jfrog.bintray/1.0) was not a valid response from a Gradle Plugin Resolution Service: content type is ‘text/html’, expected ‘application/json’

If I browse the portal URL in a browser I am able to see the correct json response.

---

<div class="post-metadata">

**Author:** ![kons](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/kons/32/19_2.png) [@kons](https://discuss.gradle.org/u/kons)\
**Post date:** [January 19, 2015, 2:55pm UTC](https://discuss.gradle.org/t/cannot-apply-plugin-with-the-plugin-dsl-when-running-behind-an-authenticated-proxy/2202/2 "2015-01-19T14:55:00Z")

</div>

Hi Rzabini  
  
Could you please send us a copy of your gradle log file?  
If you could run your build with the debug flag and please send us the output&nbsp;  
  
eg &nbsp; gradle assemble --debug  
  
If too large to attach here, please email me directly kon.soulianidis [at] gradleware [dot] com  
  
Kind Regards  
  
Kon

---

<div class="post-metadata">

**Author:** ![kons](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/kons/32/19_2.png) [@kons](https://discuss.gradle.org/u/kons)\
**Post date:** [January 20, 2015, 12:33am UTC](https://discuss.gradle.org/t/cannot-apply-plugin-with-the-plugin-dsl-when-running-behind-an-authenticated-proxy/2202/3 "2015-01-20T00:33:00Z")

</div>

Hi Rzabini

Thanks for sending through the logs.

It would appear your proxy is rejecting the https call ([https://plugins.gradle.org/api/gradle/2.2.1/plugin/use/com.jfrog.bintray/1.0](https://plugins.gradle.org/api/gradle/2.2.1/plugin/use/com.jfrog.bintray/1.0 "Link httpspluginsgradleorgapigradle221pluginusecomjfrogbintray10"))&nbsp;that the plugin dsl uses to lookup where the plugin&nbsp;jar is.

Could you please test the proxy outside of your browser using a command line utility such as curl? Your browser may be using a pac file which may treat https connections differently (route directly or via a different proxy)&nbsp;which is why it works but command line tools don’t.

An example curl command below

```
curl -U user:passwd -x[proxy.example.com:8080](http://proxy.example.com:8080) [https://plugins.gradle.org/api/gradle/2.2.1/plugin/use/com.jfrog.bintray/1.0](http://www.get.this/ "Link httpwwwgetthis")
```
The username may need to be in the form DOMAIN\username  
  
You can get curl for windows from here. &nbsp;There is also an NTLM enabled curl build, see the details on this [stack overflow post](http://stackoverflow.com/questions/1276955/ntlm-proxy-without-password "Link httpstackoverflowcomquestions1276955ntlm-proxy-without-password")  
  
The working curl command will provide some information on what to feed into the proxy system properties, and also provide you with a starting point you can escalate this with the network engineers at your site.&nbsp;  
  
Please let us know how you go with this.  
  
One final question, is this the first time you have tried using the plugin DSL at this site? (with this proxy). &nbsp;Has it worked previously?  
  
Best regards,  
Kon

---

<div class="post-metadata">

**Author:** ![rzabini](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@rzabini](https://discuss.gradle.org/u/rzabini)\
**Post date:** [January 20, 2015, 7:01am UTC](https://discuss.gradle.org/t/cannot-apply-plugin-with-the-plugin-dsl-when-running-behind-an-authenticated-proxy/2202/4 "2015-01-20T07:01:00Z")

</div>

Hi Kon, thank you for your prompt answer.

Yes, this is the first time I have tried the plugin DSL, so it did not work previously.

Anyway, as I wrote in my initial post, I am able to work through the plugin resolution by means of the “standard” syntax (not the DSL one). In that case the proxy works (and also works for git and maven).

It is only when I try to apply the “DSL syntax” that the proxy denies the authorization, so it seems to me that the plugin DSL function is somehow following a different path to establish a http connection to the Gradle plugins portal.

Best regards, Romano

---

<div class="post-metadata">

**Author:** ![kons](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/kons/32/19_2.png) [@kons](https://discuss.gradle.org/u/kons)\
**Post date:** [January 23, 2015, 12:58am UTC](https://discuss.gradle.org/t/cannot-apply-plugin-with-the-plugin-dsl-when-running-behind-an-authenticated-proxy/2202/5 "2015-01-23T00:58:00Z")

</div>

Hi Romano  
  
Glad you’ve got a work around.&nbsp;  
  
You are correct in saying that the Plugins DSL is following a different path. &nbsp;The DSL relies on the plugin portal ([plugins.gradle.org](http://plugins.gradle.org)) to identify the details that you would previously have to add to the buildscript { … } section of your build. &nbsp;  
  
It would appear that the proxy specified in the command line is preventing access to the [http **s** ://plugins.gradle.org](https://plugins.gradle.org "Link: https://plugins.gradle.org") URL. &nbsp;I’ve worked in corporate environments in the past where the proxy specified on the command line is different to what your browser uses and I have a hunch you may be experiencing the same issue, which is why it works in your browser but not on the command line.&nbsp;  
  
The reason the buildscript way works for you&nbsp;is that its only using http and not https, so the https proxy isnt being used or tested. &nbsp;  
  
It may be worth checking with the network administrators that URL&nbsp;is available via the proxy you have specified. &nbsp;The curl command provided in my last post&nbsp;would verify this too. &nbsp; Can appreciate this isn’t a priority at the moment, however as other projects incorporate the new DSL, you’ll find you will have trouble consuming those builds.  
  
Kind Regards  
  
Kon

---

<div class="post-metadata">

**Author:** ![Odin\_Hole\_Standal](https://avatars.discourse-cdn.com/v4/letter/o/7c8e57/32.png) [@Odin\_Hole\_Standal](https://discuss.gradle.org/u/Odin_Hole_Standal)\
**Post date:** [March 2, 2015, 1:42pm UTC](https://discuss.gradle.org/t/cannot-apply-plugin-with-the-plugin-dsl-when-running-behind-an-authenticated-proxy/2202/6 "2015-03-02T13:42:00Z")

</div>

Is it possible to configure the repository URL used by the new plugin DSL ? Or is it designed to only be used through the [plugins.gradle.org](http://plugins.gradle.org) portal?

---

<div class="post-metadata">

**Author:** ![Mark\_Viera](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mark_viera/32/1543_2.png) [@Mark\_Viera](https://discuss.gradle.org/u/Mark_Viera)\
**Post date:** [March 2, 2015, 4:22pm UTC](https://discuss.gradle.org/t/cannot-apply-plugin-with-the-plugin-dsl-when-running-behind-an-authenticated-proxy/2202/7 "2015-03-02T16:22:00Z")

</div>

Currently the new plugin DSL can only be used to resolve plugins against the plugin portal or core Gradle plugins. If you want to use third-party plugins that aren’t in the plugin portal you’ll have to continue to use the ‘apply plugin: …’ syntax.
