dagger/dagger · error
failed to connect to session server: %w
Error message
failed to connect to session server: %w
What it means
Returned by mainSession when the TCP dial to 127.0.0.1:<DAGGER_SESSION_PORT> fails. The session server either has not started listening yet, exited, or the port is wrong/firewalled; the subprocess cannot attach its output to the session.
Source
Thrown at cmd/init/main.go:269
func mainSession() error {
ctx := context.Background()
// this is closed when the session server is about to run, letting the parent process know that
pipeW := os.NewFile(3, "session-pipe-w")
portStr, ok := os.LookupEnv("DAGGER_SESSION_PORT")
if !ok {
return fmt.Errorf("DAGGER_SESSION_PORT not set")
}
_, err := strconv.Atoi(portStr)
if err != nil {
return fmt.Errorf("DAGGER_SESSION_PORT invalid: %w", err)
}
conn, err := (&net.Dialer{}).DialContext(ctx, "tcp", "127.0.0.1:"+portStr)
if err != nil {
return fmt.Errorf("failed to connect to session server: %w", err)
}
attachables := []client.SessionAttachable{
// secrets
secretprovider.NewSecretProvider(),
// sockets
client.SocketProvider{EnableHostNetworkAccess: true},
// host=>container networking
h2c.NewTunnelListenerAttachable(ctx),
// Git attachable
git.NewGitAttachable(ctx),
}
// filesync
filesyncer, err := client.NewFilesyncer()
if err != nil {
return err
}
attachables = append(attachables, filesyncer.AsSource(), filesyncer.AsTarget())View on GitHub (pinned to 82ba2681db)
Solutions
- Confirm the session server is running and listening on the given port
- Check for the parent process crashing before the server started
- Verify no firewall/namespace rules block localhost TCP on that port
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at cmd/init/main.go:269 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/940ac52bc1f9babc.
Report an issue: GitHub.