crowdsecurity/crowdsec · error

http server failed: %w

Error message

http server failed: %w

What it means

The non-TLS counterpart of the socket-based serve path: http.Server.Serve on the unix socket listener failed with something other than the expected graceful-shutdown sentinel, so the acquisition goroutine returns this error.

Source

Thrown at pkg/acquisition/modules/http/run.go:258

		}

		s.logger.Infof("creating unix socket on %s", s.Config.ListenSocket)
		_ = os.Remove(s.Config.ListenSocket)

		listener, err := listenConfig.Listen(ctx, "unix", s.Config.ListenSocket)
		if err != nil {
			return csnet.WrapSockErr(err, s.Config.ListenSocket)
		}

		if s.Config.TLS != nil {
			err := s.Server.ServeTLS(listener, s.Config.TLS.ServerCert, s.Config.TLS.ServerKey)
			if err != nil && err != http.ErrServerClosed {
				return fmt.Errorf("https server failed: %w", err)
			}
		} else {
			err := s.Server.Serve(listener)
			if err != nil && err != http.ErrServerClosed {
				return fmt.Errorf("http server failed: %w", err)
			}
		}

		return nil
	})

	t.Go(func() error {
		defer trace.ReportPanic()

		if s.Config.ListenAddr == "" {
			return nil
		}

		if s.Config.TLS != nil {
			s.logger.Infof("start https server on %s", s.Config.ListenAddr)

			err := s.Server.ListenAndServeTLS(s.Config.TLS.ServerCert, s.Config.TLS.ServerKey)
			if err != nil && err != http.ErrServerClosed {

View on GitHub (pinned to 909b515798)

Solutions

  1. Confirm the listen_socket path still exists and has correct permissions while the service runs.
  2. Check for conflicting processes bound to the same socket; restart the service cleanly.
  3. Inspect the wrapped inner error to distinguish socket close vs accept failure.
  4. Ensure only one crowdsec instance uses that socket (address-already-in-use style conflicts).
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := net.Listen("unix", sockPath); err != nil { return err } // probe bindability first

Try / catch

if err := serve(); err != nil && !errors.Is(err, http.ErrServerClosed) { log.Errorf("http server: %v", err) }

Prevention

When it happens

Trigger: Datasource without a TLS block using listen_socket; Serve returns a non-ErrServerClosed error, e.g. the socket file was removed mid-run, permission issues, or listener closed unexpectedly.

Common situations: Another process or cleanup job deleted/unlinked the socket file at the configured path; supervisor signals causing double-close; file descriptor exhaustion.

Related errors


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/3761b5a25db7d653. Report an issue: GitHub.