{"record":{"id":"14710f78553e6778","repo":"router-for-me/CLIProxyAPI","slug":"failed-to-start-http-server-v","errorCode":null,"errorMessage":"failed to start HTTP server: %v","messagePattern":"failed to start HTTP server: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/api/server.go","lineNumber":270,"sourceCode":"\t}\n\n\treturn s\n}\n\n// Start begins listening for and serving HTTP or HTTPS requests.\n// It's a blocking call and will only return on an unrecoverable error.\n//\n// Returns:\n//   - error: An error if the server fails to start\nfunc (s *Server) Start() error {\n\tif s == nil || s.server == nil {\n\t\treturn fmt.Errorf(\"failed to start HTTP server: server not initialized\")\n\t}\n\n\taddr := s.server.Addr\n\tlistener, errListen := net.Listen(\"tcp\", addr)\n\tif errListen != nil {\n\t\treturn fmt.Errorf(\"failed to start HTTP server: %v\", errListen)\n\t}\n\n\tuseTLS := s.cfg != nil && s.cfg.TLS.Enable\n\tif useTLS {\n\t\tcertPath := strings.TrimSpace(s.cfg.TLS.Cert)\n\t\tkeyPath := strings.TrimSpace(s.cfg.TLS.Key)\n\t\tif certPath == \"\" || keyPath == \"\" {\n\t\t\tif errClose := listener.Close(); errClose != nil {\n\t\t\t\tlog.Errorf(\"failed to close listener after TLS validation failure: %v\", errClose)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"failed to start HTTPS server: tls.cert or tls.key is empty\")\n\t\t}\n\t\tcertPair, errLoad := tls.LoadX509KeyPair(certPath, keyPath)\n\t\tif errLoad != nil {\n\t\t\tif errClose := listener.Close(); errClose != nil {\n\t\t\t\tlog.Errorf(\"failed to close listener after TLS key pair load failure: %v\", errClose)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"failed to start HTTPS server: %v\", errLoad)","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/api/server.go#L252-L288","documentation":"Error \"failed to start HTTP server: %v\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/api/server.go:270 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped error for the listen failure (e.g. port in use, permission denied).","Verify the configured listen address and port are valid and free, then restart the server."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}