Intellij Community can't use http proxy for Maven

75,760

Solution 1

I commented out the proxy config in my ~/.m2/settings.xml file, let the Intellij Proxy info alone, and then supplied the properties in Setting->Maven. Not sure why that worked (nor why the settings.xml wasn't working right) but it's working now.

Solution 2

  1. Navigate to Maven > Importing1. inside the IntelliJ IDEA Settings (which is found under File > Settings).

  2. The second last option in Maven > Importing is a field named "VM options for importer". Append the following to whatever already exists there:

    -DproxySet=true -DproxyHost=myproxy.com -DproxyPort=3128

    Here, replace myproxy.com with your proxy server, (e.g. http://myproxyserver.com). Replace 3128 with your proxy port (e.g. 8080).

  3. Do the same under Maven > Runner1

  4. Apply and close the settings window.

It should work now.


1 This may be nested under Build, Execution, Deployment > Build Tools >, depending on the version of IntelliJ you're using.

Solution 3

I had the same problem running maven inside IntelliJ whilst behind an NTLM proxy. The working solution was as follows:

  1. Download and install CNTLM. Excellent post here on how to do this https://stackoverflow.com/a/23962313/3298801
  2. Set and test your local proxy settings in IntelliJ via Settings >> System Settings >> HTTP Proxy.
  3. In Intellij set the maven runner. Within Settings >> Maven >> runner set VM options to:
    -DproxySet=true -DproxyHost=localhost -DproxyPort=3132
  4. Restart Intellij
  5. Note within ~/.m2/settings.xml I also added my proxy config as:
<proxies>
        <proxy>
            <active>true</active>
            <protocol>https</protocol>
            <host>localhost</host>
            <port>3132</port> 
        </proxy>
</proxies>

Solution 4

A little update for memo. I don't have a standalone maven installed, so finally I fixed this by modifying the maven plugin settings. settings.xml is located at :

IntelliJ IDEA Community Edition 2017.3.4\plugins\maven\lib\maven3\conf\settings.xml

You can find proxy settings and change it as mentioned above.

Solution 5

I meet the same problem.By ShadowsocksR,I can visit some websites that i can't visit without ShadowsocksR. I use Intellij , the error is "Connection timed out: connect -> [Help 1]".At last, I also added my proxy config as:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
   <proxies>
   <proxy>
      <id>example-proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>localhost</host>
      <port>1080</port>
      <username>***.***.**.***:****</username>
      <password>*******</password>
      <nonProxyHosts>www.baidu.com|*.example.com</nonProxyHosts>
    </proxy>
  </proxies>
</settings>

My computer environment is win10. http://maven.apache.org/guides/mini/guide-proxies.html

Share:
75,760
MikeHoss
Author by

MikeHoss

Updated on January 04, 2022

Comments

  • MikeHoss
    MikeHoss over 2 years

    I have Intellij IDEA Community installed on a Linux box that needs to use an authenticated proxy to get to the Internet. I have a system-wide proxy on the box that works, and I have the proxy configured in ~/.m2/settings.xml. Maven correctly uses the proxy when I run try it from the command-line.

    I have the same proxy configured within Intellij and it gives me the plugins listing correctly. But when I try to sync with the Maven repository withing Intellij I keep getting this:

    [WARNING] Unable to get resource 'org.codehaus.mojo:hibernate3-maven-plugin:pom:2.2' 
    from  repository restlet (http://maven.restlet.org): Authorization failed: Not   
    authorized by proxy.
    

    I went to Settings->Maven and put in the proxy info as properties and that didn't work. I can see by looking at those settings that Intellij is reading my ~./m2/settings.xml fine because it knows where my local repo is (it's in a non-standard place).

    Anyone know how I can get this working?

  • cal meacham
    cal meacham over 14 years
    And how is that different from what I suggested?
  • MikeHoss
    MikeHoss over 14 years
    It's not -- I was just going to comment on it. Commenting out the proxy config in the settings.xml just disabled the proxy altogether. So I thought it was working but instead it was trying to connect, couldn't, and kept trying for a while. I figured this out after I left it run for two hours. A maven update shouldn't take that long! I didn't get the same error as above -- instead I got "Unable to connect to . . ". Which means that it didn't even get to the proxy. anyone else have any ideas?
  • MikeHoss
    MikeHoss about 14 years
    I got it to mostly work -- I think the secret it to tell Intellij your config instead of trying to figure it out. Goto File->Settings-Maven and set all three Maven directories at the bottom. That got it working for me.
  • martin
    martin over 9 years
    That worked for me, since I am behind a windows proxy, and need to have cntlm installed (I use a debian installation)... Thanks!
  • Guillaume Husta
    Guillaume Husta almost 9 years
    Maybe related to this kind of bug ? youtrack.jetbrains.com/issue/IDEA-91967
  • positivecrux
    positivecrux over 8 years
    Check this link for detailed steps
  • user2023507
    user2023507 about 8 years
    For those who have an SSL connection, you also need to add -Djavax.net.ssl.trustStore=C:/myKeystores/.myNexusKeystore
  • Rick Moritz
    Rick Moritz over 5 years
    For me at least: no need to restart IntelliJ.
  • Evgenii Glotov
    Evgenii Glotov over 3 years
    adding proxy config to ~/.m2/settings.xml helped, thanks!
  • Ross A
    Ross A over 3 years
    Changing VM options made no difference for me, but adding proxy config to ~/.m2/settings.xml fixed it. Thanks!
  • Mugen
    Mugen about 3 years
    Why can't maven just consume the IDE's proxy? This should be a bug on Intellij.
  • Wojtek vanDer
    Wojtek vanDer about 2 years
    Thanks, I can confirm this works with IntelliJ IDEA 2021.3.3 and newest plugin.