# org.gradle.launcher.daemon.server.DaemonExpirationPeriodicCheck: Daemon will be stopped at the end of the build after running for 3 hours

- **ID:** `cicd/gradle-daemon-stopped`
- **Domain:** cicd
- **Category:** system_error
- **Error Code:** `GDAEMONEXPIRED`
- **Verification:** ai_generated
- **Fix Rate:** 78%

## Root Cause

Gradle's daemon process is automatically terminated due to idle timeout or maximum age limits configured in gradle.properties, causing subsequent builds to restart the daemon and lose cached state.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Gradle 8.5 | active | — | — |
| Gradle 8.7 | active | — | — |
| Gradle 7.6.3 | active | — | — |

## Workarounds

1. **Increase daemon idle timeout in gradle.properties: `org.gradle.daemon.idletimeout=7200000` (2 hours)** (85% success)
   ```
   Increase daemon idle timeout in gradle.properties: `org.gradle.daemon.idletimeout=7200000` (2 hours)
   ```
2. **Set daemon max age to a higher value: `org.gradle.daemon.registry.base.expiration=86400000` (24 hours) in gradle.properties** (80% success)
   ```
   Set daemon max age to a higher value: `org.gradle.daemon.registry.base.expiration=86400000` (24 hours) in gradle.properties
   ```
3. **Use the `--no-daemon` flag for short-lived CI builds to avoid daemon overhead, and rely on build cache instead: `gradle build --no-daemon --build-cache`** (75% success)
   ```
   Use the `--no-daemon` flag for short-lived CI builds to avoid daemon overhead, and rely on build cache instead: `gradle build --no-daemon --build-cache`
   ```

## Dead Ends

- **Set org.gradle.daemon=false in gradle.properties to disable daemon entirely** — Disabling the daemon removes the caching benefit entirely, making builds significantly slower in CI environments. (75% fail)
- **Increase the daemon heap size with -Xmx to prevent memory-related stops** — Heap size does not affect the idle timeout or age-based expiration; the daemon will still stop after the configured duration. (90% fail)
- **Restart the CI worker node to clear the daemon lock file** — Restarting the node resets the daemon but does not address the underlying configuration causing the expiration. (60% fail)
