gravitational/teleport · error

http.StatusText(status)

Error message

http.StatusText(status)

What it means

ServeHTTPError writes the standard status text (e.g. 'Bad Gateway', 'Gateway Timeout') for a mapped HTTP status: io.EOF maps to 502, net timeouts to 504, other net errors to 502, and anything unrecognized to 500. The body deliberately reveals no error detail.

Source

Thrown at lib/limiter/internal/ratelimit/http.go:48

		w.WriteHeader(http.StatusTooManyRequests)
		w.Write([]byte(err.Error()))
		return
	}

	status := http.StatusInternalServerError
	var netError net.Error

	if errors.Is(err, io.EOF) {
		status = http.StatusBadGateway
	} else if errors.As(err, &netError) {
		if netError.Timeout() {
			status = http.StatusGatewayTimeout
		} else {
			status = http.StatusBadGateway
		}
	}

	http.Error(w, http.StatusText(status), status)
}

func ExtractClientIP(r *http.Request) (string, error) {
	host, _, err := net.SplitHostPort(r.RemoteAddr)
	if err != nil || host == "" {
		return "", errors.New("failed to extract source IP")
	}

	return host, nil
}

View on GitHub (pinned to 1283425b60)

Solutions

  1. Check server logs for the underlying error behind the status
  2. For 502/504: verify upstream connectivity and timeouts, then retry
  3. For 500: inspect the rate limiter's downstream handler for the failure
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at lib/limiter/internal/ratelimit/http.go:48 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gravitational/teleport@1283425b60 (2026-09-02). Data as JSON: /api/errors/82bda0b82b55ae66. Report an issue: GitHub.