gradle/gradle · warning
Could not forward client stdin.
Error message
Could not forward client stdin.
What it means
The daemon multiplexes the client's stdin over the connection as ForwardInput/CloseInput/UserResponse commands and dispatches them to the build's StdinHandler inside a command queue. If handler.onInput(...), handler.onEndOfInput(), or handler.onUserResponse(...) throws, the exception is caught, this warning is logged, and the queue moves on (returns true, command consumed).
Source
Thrown at platforms/core-runtime/launcher/src/main/java/org/gradle/launcher/daemon/server/DefaultDaemonConnection.java:308
private static class StdinQueue extends CommandQueue<InputMessage, StdinHandler> {
private StdinQueue(ExecutorFactory executorFactory) {
super(executorFactory, "Stdin handler");
}
@Override
protected boolean doHandleCommand(final StdinHandler handler, InputMessage command) {
try {
if (command instanceof CloseInput) {
handler.onEndOfInput();
return true;
} else if (command instanceof UserResponse) {
handler.onUserResponse((UserResponse) command);
} else {
handler.onInput((ForwardInput) command);
}
} catch (Exception e) {
LOGGER.warn("Could not forward client stdin.", e);
return true;
}
return false;
}
@Override
protected void doHandleDisconnect() {
queue.clear();
queue.add(new CloseInput());
}
}
private static class CancelQueue extends CommandQueue<Cancel, Runnable> {
private CancelQueue(ExecutorFactory executorFactory) {
super(executorFactory, "Cancel handler");
}
View on GitHub (pinned to 534f27719b)
Solutions
- Check the attached exception - if the build was already aborting or finished, the warning is harmless
- Do not feed stdin to non-interactive/daemon builds; use -q, --console=plain, or close the pipe
- For prompts, prefer passing answers via properties or a file instead of live stdin through the daemon
- Re-run the build - stdin forwarding state is per-connection and resets
Example fix
# before: CI pipes stdin into a daemon build that never reads it cat answers.txt | ./gradlew ask # after: pass answers as a property, keep stdin closed ./gradlew ask -PanswersFile=answers.txt < /dev/null
Defensive patterns
Strategy: validation
Validate before calling
// only forward stdin for builds that actually read it
boolean buildReadsStdin = Boolean.getBoolean("mybuild.interactive");
if (!buildReadsStdin) System.in.close(); // daemon gets no stdin to mis-forward Prevention
- Redirect stdin from /dev/null for non-interactive daemon builds ('< /dev/null')
- Pass interactive answers via -P properties or files instead of piping them through the daemon
- Remember stdin handling is per-client-connection; a fresh build resets it
When it happens
Trigger: A stdin command arrives but the build-side stdin handler fails - build input stream already closed, console/encoding errors, or an interactive build that finished while further stdin commands were still queued.
Common situations: Piping stdin into a Gradle build that prompts interactively while running in the daemon; CI jobs with closed stdin; pressing Ctrl+C during an interactive prompt; tools streaming input to 'gradle' after the build completed.
Related errors
- Cannot generate the deserialization method for class " + cla
- Could not determine the class-path for %s.
- A new daemon was started but could not be connected to. This
- Connected to a stale daemon address.
- The first result from the daemon was empty. The daemon proce
AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22).
Data as JSON: /api/errors/5841f259b50ceba6.
Report an issue: GitHub.