{"record":{"id":"0e917082915aa529","repo":"gravitational/teleport","slug":"could-not-connect-to-the-vnet-daemon-within-the-ti","errorCode":null,"errorMessage":"could not connect to the VNet daemon within the timeout","messagePattern":"could not connect to the VNet daemon within the timeout","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/vnet/daemon/client_darwin.go","lineNumber":239,"sourceCode":"\t\treturn \"not registered\"\n\tcase ServiceStatusEnabled:\n\t\treturn \"enabled\"\n\tcase ServiceStatusRequiresApproval:\n\t\treturn \"requires approval\"\n\tcase ServiceStatusNotFound:\n\t\treturn \"not found\"\n\tcase ServiceStatusNotSupported:\n\t\treturn \"not supported\"\n\tdefault:\n\t\treturn strconv.Itoa(int(s))\n\t}\n}\n\nfunc startByCalling(ctx context.Context, bundlePath string, config Config) error {\n\t// C.StartVnet might hang if the daemon cannot be successfully spawned.\n\tconst daemonStartTimeout = 20 * time.Second\n\tctx, cancel := context.WithTimeoutCause(ctx, daemonStartTimeout,\n\t\terrors.New(\"could not connect to the VNet daemon within the timeout\"))\n\tdefer cancel()\n\n\tdefer C.InvalidateDaemonClient()\n\n\terrC := make(chan error, 1)\n\n\tgo func() {\n\t\treq := C.StartVnetRequest{\n\t\t\tbundle_path:                     C.CString(bundlePath),\n\t\t\tservice_credential_path:         C.CString(config.ServiceCredentialPath),\n\t\t\tclient_application_service_addr: C.CString(config.ClientApplicationServiceAddr),\n\t\t}\n\t\tdefer func() {\n\t\t\tC.free(unsafe.Pointer(req.bundle_path))\n\t\t\tC.free(unsafe.Pointer(req.service_credential_path))\n\t\t\tC.free(unsafe.Pointer(req.client_application_service_addr))\n\t\t}()\n","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/gravitational/teleport/blob/1283425b60ec5f60d509ba4c791183d452923ff7/lib/vnet/daemon/client_darwin.go#L221-L257","documentation":"Raised in startByCalling (lib/vnet/daemon/client_darwin.go:239) as the context.Cause of a 20-second deadline. The C.StartVnet XPC call can hang if the daemon cannot be successfully spawned, so the client bounds the start attempt; if no response arrives within 20 seconds this error is returned (wrapped with 'connecting to the VNet daemon').","triggerScenarios":"RegisterAndCall -> startByCalling where the daemon fails to spawn or never replies to the StartVnet XPC message: launchd job misconfigured, daemon binary failing to launch, XPC service stuck, or the daemon deadlocked on startup.","commonSituations":"Corrupted or invalid app bundle; daemon crashing silently at spawn; launchd backpressure on a busy system; conflicting/stale daemon job definition; daemon blocked during startup handshake.","solutions":["Check launchd and daemon logs (Console.app, `log show --predicate 'process == \"tsh\"'`) to see why the daemon did not spawn or respond.","Verify the app bundle path and daemon label are correct; re-register the daemon (RegisterDaemon) and retry.","Reboot the Mac or bootout/bootstrap the launchd job to clear a stuck service, then retry tsh vnet start."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify the daemon binary exists and launchd job is defined before attempting start\nif _, err := os.Stat(bundlePath); err != nil {\n    return fmt.Errorf(\"daemon bundle missing at %s: %w\", bundlePath, err)\n}","typeGuard":null,"tryCatchPattern":"err := client.RegisterAndCall(ctx, bundlePath, cfg)\nif err != nil && strings.Contains(err.Error(), \"could not connect to the VNet daemon within the timeout\") {\n    // inspect launchd/daemon logs, re-register, then retry once\n    err = client.RegisterAndCall(ctx, bundlePath, cfg)\n}","preventionTips":["Keep a bounded retry around daemon start, mirroring the 20s timeout.","Monitor daemon startup logs for spawn failures or hangs.","Re-register the daemon after bundle or label changes."],"tags":["macos","xpc","timeout","vnet","daemon"],"backgroundTag":"daemon-start-timeout","analyzedSha":"1283425b60ec5f60d509ba4c791183d452923ff7","analyzedAt":"2026-09-02T04:06:41.601Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}