Siyaram Malav
Siyaram Malav

Reputation: 4708

Intelli J IDEA Unable to open debugger port (localhost:8787): java.io.IOException "handshake failed - connection prematurally closed"

I am trying for remote debugging a java test file in intelli J IDEA.But i am getting following error.

Error running 'test': Unable to open debugger port (localhost:8787): java.io.IOException "handshake failed - connection prematurally closed"

I have seen solutions of editing command line argument, but it does not allow in 2019.2(ultimate edition).

Below is my configuration.

Blockquote

please help.

Upvotes: 2

Views: 9560

Answers (1)

Roger Gustavsson
Roger Gustavsson

Reputation: 1709

The java command that is running in the container needs to have the following parameter, together with any other parameters already there.

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8787

When the image for the container is created, port 8787 needs to be exposed by adding the following line in Dockerfile:

EXPOSE 8787

When you create the container, you need to specify that port 8787 should be tunneled to your docker host. If you are using docker-compose add the following under the specific container section:

ports:
  - '8787:8787'

If you are using docker create the parameter is --publish=8787:8787.

If all this has been setup correctly it should now be possible for the debugger to connect to localhost:8787.

Upvotes: 2

Related Questions