Skip to content

Instantly share code, notes, and snippets.

@softwaredoug
Last active April 12, 2020 15:34
Show Gist options
  • Save softwaredoug/5d96b55389b1b9f1a4495ca60168b79a to your computer and use it in GitHub Desktop.
Save softwaredoug/5d96b55389b1b9f1a4495ca60168b79a to your computer and use it in GitHub Desktop.
Debug Elasticsearch in IntelliJ (in 2020)

You used to be able to debug Elasticsearch (and plugins) by doing

./gradlew run --debug-jvm

This would launch Elasticsearch in debug mode, whereby you'd subsequently connect IntelliJ the running Elasticsearch JVM. However, if you try this after Elasticsearch 7.5, you'll get the error:

Running elasticsearch in debug mode, node{::integTest-0} suspending until connected on debugPort 5005
Exec output and error:
| Output for ./bin/elasticsearch-plugin:ERROR: transport error 202: connect failed: Connection refused
| ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
| JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:735]

The classic way of debugging Elasticsearch has changed as of ES 7.5, and now you must configure IntelliJ to listen on 5005 prior to running ./gradlew run --debug-jvm. Here's what you need to do:

Be sure you have a recent version of IntelliJ:

  • Create a new Remote run config, in that config:
  • Set "Debugger Mode" to "Listen to Remove JVM"
  • Click "Auto Restart" (missing from earlier versions of IntelliJ)

Run this Configuration, and IntelliJ will listen for a debug connection...

Back to your command line, run ./gradlew run --debug-jvm and you should be able debug Elasticsearch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment