Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Gradle builds fall back to compiling without the Kotlin daemon

ErrorFailed to compile with Kotlin daemon: java.lang.RuntimeException: Could not connect to Kotlin compile daemon

Short answer

The Kotlin compiler normally runs in its own daemon. When Gradle cannot talk to it, the compiler falls back to running inside the Gradle process and prints this warning. Stop all Gradle daemons first. If it keeps coming back, set kotlin.compiler.execution.strategy=in-process, or turn the fallback off to see the real startup error.

  • Applies to Kotlin 2.x, Gradle 8.x and 9.x, JDK 17 and 21
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List the running Gradle daemons. A stale or busy one from another Java version is the first thing to remove.

    .\gradlew.bat --status
    .\gradlew.bat --stop
  2. 2Match what you see, then jump to its fix

    1. 1The build output ends with the hint to try ./gradlew --stopA stale daemon blocks communicationFix
    2. 2The warning returns on every build even after --stopThe daemon cannot be reached in this environmentFix

What does the error look like?

  • Failed to compile with Kotlin daemon: java.lang.RuntimeException: Could not connect to Kotlin compile daemon
  • Using fallback strategy: Compile without Kotlin daemon
  • Try ./gradlew --stop if this issue persists.

Cause 1 of 2

A stale daemon blocks communication

1Check

Gradle reuses a daemon only when the Java version, JVM attributes and Gradle version match, so old daemons from a previous setup can pile up. The Kotlin documentation itself suggests stopping them.

.\gradlew.bat --status

2Fix

Stop the daemons and build again.

.\gradlew.bat --stop

3Verify

Run the build; the fallback warning is gone.

.\gradlew.bat assembleDebug

Confirmed by docs.gradle.org

Did this fix it?

Cause 2 of 2

The daemon cannot be reached in this environment

1Check

Switch off the silent fallback so the build fails and prints the real daemon startup or communication problem, instead of continuing slowly.

# gradle.properties
kotlin.daemon.useFallbackStrategy=false

2Fix

If you cannot fix the cause, run the compiler inside the Gradle process. The compiler then runs inside the Gradle process and does not need the daemon.

# gradle.properties
kotlin.compiler.execution.strategy=in-process

3Verify

Build again; no daemon warning appears and the compile step completes.

.\gradlew.bat assembleDebug --info

Confirmed by kotlinlang.org

Did this fix it?

How do I stop it coming back?

  • Run ./gradlew --stop after changing the JDK or Gradle version.
  • Keep one JDK for the project instead of mixing Studio's and a terminal's.
  • Do not leave the in-process strategy on for good unless the daemon cannot work on that machine.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.