The Gradle daemon dies in the middle of a Jenkins or CI build
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)Short answer
The process that runs your build vanished before it reported back. Read the daemon's own log first. The usual causes are a heap that is too small for the project and too many daemons started by mixed JDKs, Gradle versions or JVM arguments, which then compete for the agent's memory.
Fix it fast
1Find out which cause you have
Every daemon writes a log named after its process id. Open the newest one for your Gradle version; its last lines say what the daemon was doing.
ls -t ~/.gradle/daemon/*/daemon-*.out.log | head -3 tail -n 60 "$(ls -t ~/.gradle/daemon/*/daemon-*.out.log | head -1)"2Match what you see, then jump to its fix
What does the error look like?
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
Cause 1 of 2
The daemon heap is too small for this project
1Check
A daemon that gets no maximum heap setting is limited to 512MB. Look for the setting in the project and in the user home.
grep -n "org.gradle.jvmargs" gradle.properties ~/.gradle/gradle.properties2Fix
Set a larger heap for the daemon, using a value the agent can actually spare.
# gradle.properties
org.gradle.jvmargs=-Xmx2048M3Verify
Run the job again; a daemon with the new arguments is started.
./gradlew assembleReleaseConfirmed by docs.gradle.org
Cause 2 of 2
Mixed JDKs, Gradle versions or JVM arguments start extra daemons
1Check
A daemon is reused only when its Java home and JVM arguments match, so a different JDK, Gradle version or jvmargs value starts another one, using more CPU and memory.
jps | grep -i GradleDaemon2Fix
Use one JDK and one wrapper version across jobs that share an agent, then stop the leftover daemons.
./gradlew --stop
./gradlew --version3Verify
After the next build only one daemon is listed.
jps | grep -i GradleDaemonConfirmed by docs.gradle.org
How do I stop it coming back?
- Pin the Gradle version through the wrapper and the JDK through the Jenkins tool configuration.
- Set org.gradle.jvmargs in the repository so every agent starts the daemon the same way.
- Keep the daemon log directory when a build fails, so the cause is not lost with the workspace.
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
Mobile apps
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile apps
adb tcpip 5555 fails because no device is found
adb: more than one device/emulator
adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.
4 causes, each with a fixMobile apps
The Android Emulator says /dev/kvm is not found
KVM acceleration can NOT be used
The emulator wants a hypervisor and cannot find one.
4 causes, each with a fixMobile apps
The emulator says the GPU driver is unsupported and falls back to software
vulkan-1.dll cannot be found
The emulator picks a graphics mode when it starts.
4 causes, each with a fix