Unable to import Maven project, import fails with error: Cannot reconnect
Symptoms
Maven import fails with error Unable to import Maven project. idea.log has the exception:
2020-02-28 11:26:44,513 [177112990] WARN - ution.rmi.RemoteProcessSupport - java.rmi.NotBoundException: _DEAD_HAND_
2020-02-28 11:26:44,514 [177112991] WARN - ution.rmi.RemoteProcessSupport - at java.rmi/sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:234)
2020-02-28 11:26:44,514 [177112991] WARN - ution.rmi.RemoteProcessSupport - at com.intellij.execution.rmi.RemoteServer.start(RemoteServer.java:93)
2020-02-28 11:26:44,514 [177112991] WARN - ution.rmi.RemoteProcessSupport - at org.jetbrains.idea.maven.server.RemoteMavenServer36.main(RemoteMavenServer36.java:23)
2020-02-28 11:26:44,864 [177113341] WARN - ution.rmi.RemoteProcessSupport - The cook failed to start due to java.io.EOFException
2020-02-28 11:26:44,864 [177113341] ERROR - #org.jetbrains.idea.maven - Cannot reconnect.
java.lang.RuntimeException: Cannot reconnect.
at org.jetbrains.idea.maven.server.RemoteObjectWrapper.perform(RemoteObjectWrapper.java:82)
and
Caused by: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused (Connection refused)
at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at java.rmi/sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:209)
at java.rmi/sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:196)
Cause
IDE launches Maven import in a separate java process and communicates with it using java RMI calls which work via local loopback interface (localhost). To access the loopback interface the localhost hostname is used. When IDE is unable to establish connection to a localhost this error occurs. There could be several causes why localhost is not accessible:
- DNS misconfiguration
The 127.0.0.1 is the standard address for IPv4 loopback traffic and the localhost name must resolve to 127.0.0.1 IPv4 address. If it is not - the error will occur.
- Antivirus or firewall blocks connections to localhost
Resolution
- Make sure the localhost hostname resolves to 127.0.0.1 IPv4 loopback address. It is better to leave only localhost name for the 127.0.0.1 address. For this the hosts file must have only following lines for mapping localhost to IPv4 and IPv6 local addresses:
127.0.0.1 localhost
::1 localhost
It is better to remove other mappings for 127.0.0.1 ip address and localhost name.
- Make sure the antivirus or firewall are configured to allow localhost connections and IDE is allowed to make connections on the system.
For example there is a known issue with ESET network protection that blocks localhost. The workaround is to configure ESET to allow localhost connections:
>The issue should be resolved in next service release.
>Work around is to creating a rule to allow the localhost connections.
Please sign in to leave a comment.
This also seems to happen when downloading sources of a dependency (Maven project). I noticed a reboot of IntelliJ helps. But only a while, after that the same:
java.lang.RuntimeException: Cannot reconnect.
at org.jetbrains.idea.maven.server.RemoteObjectWrapper.perform(RemoteObjectWrapper.java:82)
at org.jetbrains.idea.maven.server.MavenEmbedderWrapper.customizeForResolve(MavenEmbedderWrapper.java:52)
at org.jetbrains.idea.maven.project.MavenProjectResolver.downloadSourcesAndJavadocs(MavenProjectResolver.java:253)
at org.jetbrains.idea.maven.project.MavenProjectsProcessorArtifactsDownloadingTask.perform(MavenProjectsProcessorArtifactsDownloadingTask.java:40)
at org.jetbrains.idea.maven.project.MavenProjectsProcessor.doProcessPendingTasks(MavenProjectsProcessor.java:145)
at org.jetbrains.idea.maven.project.MavenProjectsProcessor.access$000(MavenProjectsProcessor.java:36)
at org.jetbrains.idea.maven.project.MavenProjectsProcessor$1.run(MavenProjectsProcessor.java:114)
at org.jetbrains.idea.maven.utils.MavenUtil.lambda$runInBackground$5(MavenUtil.java:494)
at com.intellij.util.RunnableCallable.call(RunnableCallable.java:20)
at com.intellij.util.RunnableCallable.call(RunnableCallable.java:11)
at com.intellij.openapi.application.impl.ApplicationImpl$1.call(ApplicationImpl.java:268)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused (Connection refused)
at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:623)
at java.rmi/sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:209)
at java.rmi/sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:196)
at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:132)
at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:217)
at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:162)
at com.sun.proxy.$Proxy126.createEmbedder(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.intellij.execution.rmi.RemoteUtil.invokeRemote(RemoteUtil.java:155)
at com.intellij.execution.rmi.RemoteUtil.access$400(RemoteUtil.java:25)
(and yes, firewall is set up correctly, as i said it works for a while as well).
Stefan please see this thread IDEA-247792.
please solve it
The issue still exists. It makes me crazy to try to update if some changed pom.xml. This issue should became critical! Awful tool
Please try 2023.1 (currently in RC state) - it has improvements which fix Maven frequent disconnects issues.
I am running on WSL2. First, I created a rule in Windows Firewall (Adanced Settings) to allow outbound traffic on port 80. Then:
In PowerShell, run:
In Bash (WSL2), run to assert outbound allowed traffic on port 80: