javamavenintellij-ideaconnection-refused

"Connection refused to host ::1" when reloading Maven in IDEA


This is IDEA 2023.2.2 Ultimate, though I just updated today and this was certainly a problem before. M1 Macbook on Ventura 13.5.2.

Whenever I open IDEA, I'm presented with this in the Sync tab, with no further trace:

java.util.concurrent.ExecutionException: java.rmi.ConnectException: Connection refused to host: ::1; nested exception is: 
    java.net.ConnectException: Connection refused

I more or less ignored this until today, when I needed to introduce a new Maven dependency and found myself completely unable to do so. I added a new <dependency> entry to pom.xml, but there is no way to get IDEA to accept it. Clicking Reload All Maven Projects immediately gives me the above error every time. The new dependency never appears in External Libraries and it's unavailable when developing.

Strangely, running mvn dependency:tree in my terminal, whether outside or within IDEA, seems to work fine. I see the new one in the list. But in neither case does it have any effect in IDEA.

My teammate has the same Maven configuration (which I've never touched) and he was able to get the new dependency just fine after checking out my branch, so I'm kind of going nuts here. Being on or off VPN doesn't seem to have any effect.

/etc/hosts, if that matters, is

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

/Users/tyler/.m2/settings.xml doesn't exist for me. The same is true for my teammates, though.

Here are some relevant Maven settings:

Screenshot of my IDEA Maven settings

Screenshot of more IDEA Maven settings


Solution

  • IDEA runs Maven Daemon as a separate process, which it communicates with using RMI/loopback. Judging from the error message you are getting, something is preventing IDEA from talking to Maven Daemon.

    This is most often caused by firewalls and/or security solutions. See also:

    https://intellij-support.jetbrains.com/hc/en-us/articles/360014262940-Unable-to-import-Maven-project-import-fails-with-error-Cannot-reconnect

    Note that your computer seems to be using IPv6, which may make this more complicated. For instance, IPv6 may have a different set of firewall/routing rules. You can try switching to IPv4 to see if that helps.