{"record":{"id":"940ac52bc1f9babc","repo":"dagger/dagger","slug":"failed-to-connect-to-session-server-w","errorCode":null,"errorMessage":"failed to connect to session server: %w","messagePattern":"failed to connect to session server: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/init/main.go","lineNumber":269,"sourceCode":"\nfunc mainSession() error {\n\tctx := context.Background()\n\n\t// this is closed when the session server is about to run, letting the parent process know that\n\tpipeW := os.NewFile(3, \"session-pipe-w\")\n\n\tportStr, ok := os.LookupEnv(\"DAGGER_SESSION_PORT\")\n\tif !ok {\n\t\treturn fmt.Errorf(\"DAGGER_SESSION_PORT not set\")\n\t}\n\t_, err := strconv.Atoi(portStr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"DAGGER_SESSION_PORT invalid: %w\", err)\n\t}\n\n\tconn, err := (&net.Dialer{}).DialContext(ctx, \"tcp\", \"127.0.0.1:\"+portStr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to connect to session server: %w\", err)\n\t}\n\n\tattachables := []client.SessionAttachable{\n\t\t// secrets\n\t\tsecretprovider.NewSecretProvider(),\n\t\t// sockets\n\t\tclient.SocketProvider{EnableHostNetworkAccess: true},\n\t\t// host=>container networking\n\t\th2c.NewTunnelListenerAttachable(ctx),\n\t\t// Git attachable\n\t\tgit.NewGitAttachable(ctx),\n\t}\n\t// filesync\n\tfilesyncer, err := client.NewFilesyncer()\n\tif err != nil {\n\t\treturn err\n\t}\n\tattachables = append(attachables, filesyncer.AsSource(), filesyncer.AsTarget())","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/cmd/init/main.go#L251-L287","documentation":"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.","triggerScenarios":"Thrown at cmd/init/main.go:269 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}