I'm trying to do remote debugging with Maven and Eclipse. On the remote machine, I do `mvnDebug spring-boot:run`, and on the local machine in Eclipse, I set up a *Remote Java Application* debug configuration with the appropriate host IP and port and Connection Type as *Standard (Socket Attach)*.

On the remote machine, before attempting to connect with Eclipse, I only see:

```
Preparing to execute Maven in debug mode
Listening for transport dt_socket at address: 8000

```

`ss -aln` shows something listening on port 8000: `users:(("java",pid=949917,fd=4))`. As soon as I start the debug process in Eclipse on the local machine, the regular Maven output appears on the remote machine:

```
Apache Maven 3.6.3 (NON-CANONICAL_2019-11-27T20:26:29Z_root)                                                 
Maven home: /opt/maven                                                                                       
Java version: 1.8.0_242, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-8-openjdk/jre                
Default locale: en_US, platform encoding: UTF-8                                                              
OS name: "linux", version: "5.5.8-arch1-1", arch: "amd64", family: "unix"                                    
[INFO] Scanning for projects...
...

```

so apparently a connection is made. The output from Maven is identical to a regular run. But Eclipse displays `Failed to connect to remote VM. Connection refused.` with no additional information, and by now nothing is listening on port 8000 on the remote machine anymore.

I don't have any idea how to even debug this, and the config couldn't be simpler.

The contents of the `mvnDebug` script are:

```
MAVEN_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"

echo Preparing to execute Maven in debug mode

env MAVEN_OPTS="$MAVEN_OPTS" MAVEN_DEBUG_OPTS="$MAVEN_DEBUG_OPTS" "`dirname "$0"`/mvn" "$@"

```

Any suggestions or insight would be appreciated.