{"record":{"id":"f4e92690c07928bf","repo":"crowdsecurity/crowdsec","slug":"no-listen-uri-or-listen-socket-specified","errorCode":null,"errorMessage":"no listen_uri or listen_socket specified","messagePattern":"no listen_uri or listen_socket specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/csconfig/api.go","lineNumber":369,"sourceCode":"\t}\n\n\tif c.API.Server.Enable == nil {\n\t\t// if the option is not present, it is enabled by default\n\t\tc.API.Server.Enable = new(true)\n\t}\n\n\tif !*c.API.Server.Enable {\n\t\tlog.Warning(\"crowdsec local API is disabled because 'enable' is set to false\")\n\n\t\tc.DisableAPI = true\n\t}\n\n\tif c.DisableAPI {\n\t\treturn nil\n\t}\n\n\tif c.API.Server.ListenURI == \"\" && c.API.Server.ListenSocket == \"\" {\n\t\treturn errors.New(\"no listen_uri or listen_socket specified\")\n\t}\n\n\tif c.API.Server.OnlineClient != nil && c.API.Server.OnlineClient.CredentialsFilePath != \"\" && !skipOnlineCreds {\n\t\tif err := c.API.Server.OnlineClient.Load(); err != nil {\n\t\t\treturn fmt.Errorf(\"loading online client credentials: %w\", err)\n\t\t}\n\t}\n\n\tif (c.API.Server.OnlineClient == nil || c.API.Server.OnlineClient.Credentials == nil) && !inCli {\n\t\tlog.Info(\"push and pull to Central API disabled\")\n\t}\n\n\t// Set default values for CAPI push/pull\n\tif c.API.Server.OnlineClient != nil {\n\t\tif c.API.Server.OnlineClient.PullConfig.Community == nil {\n\t\t\tc.API.Server.OnlineClient.PullConfig.Community = new(true)\n\t\t}\n","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csconfig/api.go#L351-L387","documentation":"LoadAPIServer configures the local API server but only when the DisableAPI flag is false. If the server is enabled yet defines neither api.server.listen_uri nor api.server.listen_socket, there is nothing to bind, so config loading fails with this error.","triggerScenarios":"Running the LAPI (e.g. via _lapi / crowdsec with api.server enabled) where config.yaml has api.server with empty listen_uri and no listen_socket; explicitly setting api.server.listen_uri: '' while disabling the socket.","commonSituations":"Hand-edited config that removed the default listen_uri 127.0.0.1:8080; container images where the default config was partially stripped; users intending to disable the API by blanking the listen address instead of using disable_api: true.","solutions":["Set api.server.listen_uri (e.g. 127.0.0.1:8080) or api.server.listen_socket (e.g. /run/crowdsec/lapi.sock)","If the API is not wanted, set api.server.disable_api: true (or enable only the client side)","Restore the default config.yaml from the distribution package if it was accidentally emptied"],"exampleFix":"// before\napi:\n  server:\n    listen_uri: \"\"\n// after\napi:\n  server:\n    listen_uri: 127.0.0.1:8080","handlingStrategy":"validation","validationCode":"if !cfg.API.Server.DisableAPI && cfg.API.Server.ListenURI == \"\" && cfg.API.Server.ListenSocket == \"\" {\n    cfg.API.Server.ListenURI = \"127.0.0.1:8080\" // or fail fast before LoadAPIServer\n}\nif err := cfg.LoadAPIServer(false); err != nil { ... }","typeGuard":null,"tryCatchPattern":"if err := cfg.LoadAPIServer(skipOnlineCreds); err != nil {\n    return fmt.Errorf(\"api server config: %w\", err)\n}","preventionTips":["Keep the default listen_uri in any minimal config.yaml","Use disable_api: true to disable the server, never blank listen_uri","Lint crowdsec configs on deploy to catch stripped server blocks"],"tags":["go","config","lapi","crowdsec"],"backgroundTag":"missing-required-config-field","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}