# org.gradle.launcher.daemon.server.DaemonExpirationPeriodicCheck: Daemon will be stopped at the end of the build after running for 3 hours and exceeding the 2-hour idle timeout.

- **ID:** `cicd/gradle-daemon-stopped-before-finish`
- **Domain:** cicd
- **Category:** runtime_error
- **Error Code:** `DAEMON_EXPIRATION`
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

Gradle Daemon is configured with a low idle timeout (e.g., 2 hours) and the build runs longer than that, causing the daemon to be killed before the build completes, especially on long-running CI jobs.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Gradle 7.5 | active | — | — |
| Gradle 8.0 | active | — | — |
| Gradle 8.2 | active | — | — |

## Workarounds

1. **Increase the daemon idle timeout in gradle.properties: org.gradle.daemon.idletimeout=7200000 (2 hours in milliseconds) or set it to 0 to disable idle timeout.** (85% success)
   ```
   Increase the daemon idle timeout in gradle.properties: org.gradle.daemon.idletimeout=7200000 (2 hours in milliseconds) or set it to 0 to disable idle timeout.
   ```
2. **Disable the Gradle Daemon for CI builds by adding --no-daemon to the Gradle command, forcing a new JVM for each build.** (80% success)
   ```
   Disable the Gradle Daemon for CI builds by adding --no-daemon to the Gradle command, forcing a new JVM for each build.
   ```
3. **Split the build into smaller, parallel tasks to reduce individual build time below the idle timeout threshold.** (75% success)
   ```
   Split the build into smaller, parallel tasks to reduce individual build time below the idle timeout threshold.
   ```

## Dead Ends

- **** — The daemon idle timeout is a Gradle configuration parameter, not a cache or runner issue. (75% fail)
- **** — Heap size affects memory, not the daemon's idle timeout behavior. (80% fail)
- **** — The timeout is set in gradle.properties or via command line flags, not by installation. (70% fail)
