{"record":{"id":"08735a13f004ceb3","repo":"thanos-io/thanos","slug":"serve-http-and-metrics","errorCode":null,"errorMessage":"serve HTTP and metrics","messagePattern":"serve HTTP and metrics","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/server/http/http.go","lineNumber":83,"sourceCode":"\t\topts:   options,\n\t}\n}\n\n// ListenAndServe listens on the TCP network address and handles requests on incoming connections.\nfunc (s *Server) ListenAndServe() error {\n\tlevel.Info(s.logger).Log(\"msg\", \"listening for requests and metrics\", \"address\", s.opts.listen)\n\terr := toolkit_web.Validate(s.opts.tlsConfigPath)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"server could not be started\")\n\t}\n\n\tflags := &toolkit_web.FlagConfig{\n\t\tWebListenAddresses: &([]string{s.opts.listen}),\n\t\tWebSystemdSocket:   ofBool(false),\n\t\tWebConfigFile:      &s.opts.tlsConfigPath,\n\t}\n\n\treturn errors.Wrap(toolkit_web.ListenAndServe(s.srv, flags, logutil.GoKitLogToSlog(s.logger)), \"serve HTTP and metrics\")\n}\n\n// Shutdown gracefully shuts down the server by waiting,\n// for specified amount of time (by gracePeriod) for connections to return to idle and then shut down.\nfunc (s *Server) Shutdown(err error) {\n\tlevel.Info(s.logger).Log(\"msg\", \"internal server is shutting down\", \"err\", err)\n\tif err == http.ErrServerClosed {\n\t\tlevel.Warn(s.logger).Log(\"msg\", \"internal server closed unexpectedly\")\n\t\treturn\n\t}\n\n\tif s.opts.gracePeriod == 0 {\n\t\ts.srv.Close()\n\t\tlevel.Info(s.logger).Log(\"msg\", \"internal server is shutdown\", \"err\", err)\n\t\treturn\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), s.opts.gracePeriod)","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/server/http/http.go#L65-L101","documentation":"Raised in http.Server.ListenAndServe as the return of toolkit_web.ListenAndServe: after successful config validation, serving HTTP and metrics failed — bind failure on the listen address, or a runtime error from the toolkit web server (TLS handshake config issues, listener closed).","triggerScenarios":"Thrown at pkg/server/http/http.go:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the --web listen address is free and bindable","Inspect the wrapped error for TLS or listener failures","Verify systemd socket activation settings match the configuration"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}