{"record":{"id":"493e4284438f8d2b","repo":"kopia/kopia","slug":"too-many-activated-sockets-found-expected-1-got","errorCode":null,"errorMessage":"Too many activated sockets found.  Expected 1, got %v","messagePattern":"Too many activated sockets found\\.  Expected 1, got (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command_server_tls.go","lineNumber":63,"sourceCode":"\tif err != nil {\n\t\treturn errors.Wrap(err, \"socket-activation error\")\n\t}\n\n\tswitch len(listeners) {\n\tcase 0:\n\t\tif after, ok := strings.CutPrefix(httpServer.Addr, \"unix:\"); ok {\n\t\t\tl, err = (&net.ListenConfig{}).Listen(ctx, \"unix\", after)\n\t\t} else {\n\t\t\tl, err = (&net.ListenConfig{}).Listen(ctx, \"tcp\", httpServer.Addr)\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"listen error\")\n\t\t}\n\tcase 1:\n\t\tl = listeners[0]\n\tdefault:\n\t\treturn errors.Errorf(\"Too many activated sockets found.  Expected 1, got %v\", len(listeners))\n\t}\n\n\tif err := insecureserverbind.ValidateListenerAddrIfRestricted(\n\t\tc.serverStartInsecure,\n\t\tc.serverStartWithoutPassword,\n\t\tc.serverStartAllowDangerousUnauthenticatedNetwork,\n\t\tl.Addr(),\n\t); err != nil {\n\t\tl.Close() //nolint:errcheck\n\n\t\treturn errors.Wrap(err, \"insecure server bind validation\")\n\t}\n\n\tdefer l.Close() //nolint:errcheck\n\n\thttpServer.Addr = l.Addr().String()\n\n\treturn c.startServerWithOptionalTLSAndListener(ctx, httpServer, l)","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/cli/command_server_tls.go#L45-L81","documentation":"startServerWithOptionalTLS uses socket activation (systemd-style LISTEN_FDS); if more than one pre-activated socket is passed to the process, it refuses to guess which to use and returns this error. It is a guard against ambiguous multi-socket activation.","triggerScenarios":"Launching `kopia server start` with LISTEN_FDS/LISTEN_FDNAMES set to more than one socket, e.g. a systemd socket unit with multiple ListenStream= entries or ListenStream= plus ListenDatagram=.","commonSituations":"systemd .socket units with several Listen directives; container supervisors passing multiple inherited fds; misconfigured activation environment variables left set in a service file.","solutions":["Configure only ONE ListenStream=/socket in the systemd socket unit (e.g. split into separate units)","Check the environment: unset/fix LISTEN_FDS, LISTEN_FDNAMES, LISTEN_PID before starting Kopia manually","Skip socket activation and pass an explicit --address instead"],"exampleFix":"# before\n[Socket]\nListenStream=0.0.0.0:51515\nListenStream=/run/kopia.sock\n# after\n[Socket]\nListenStream=0.0.0.0:51515","handlingStrategy":"validation","validationCode":"if os.Getenv(\"LISTEN_FDS\") != \"\" {\n    n, _ := strconv.Atoi(os.Getenv(\"LISTEN_FDS\"))\n    if n > 1 { log.Fatal(\"kopia supports exactly 1 activated socket\") }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep one ListenStream per systemd socket unit","Audit service environments for stray LISTEN_FDS/LISTEN_FDNAMES","Prefer explicit --address over socket activation when unsure"],"tags":["socket-activation","systemd","config"],"backgroundTag":"invalid-argument-value","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}