netbirdio/netbird · error

authentication service unavailable

Error message

authentication service unavailable

What it means

Sentinel-based branch in forwardWithHeaderAuth: validateSessionToken failed with errValidationUnavailable, meaning the error is infrastructural — the validation backend (key/service needed to verify session tokens) is unavailable — rather than the token being bad. Surfaced to the client as 502 Bad Gateway so callers know to retry rather than re-authenticate.

Solutions

  1. Retry the request after a short delay; the condition is expected to be transient
  2. Check the health of the session-token validation service or key source the proxy depends on
  3. Inspect proxy logs for the underlying error that produced errValidationUnavailable
  4. If persistent, restart the proxy or restore the backing service before clients can authenticate
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at proxy/internal/auth/middleware.go:472 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/cb351f35a28f5728. Report an issue: GitHub.

Appendix: source

Thrown at proxy/internal/auth/middleware.go:472

func (mw *Middleware) tryHeaderScheme(w http.ResponseWriter, r *http.Request, host string, config DomainConfig, hdr Header, next http.Handler) bool {
	token, _, err := hdr.Authenticate(r)
	if err != nil {
		return mw.handleHeaderAuthError(w, r, err)
	}
	if token == "" {
		return false
	}

	result, err := mw.validateSessionToken(r.Context(), host, token, config.SessionPublicKey, auth.MethodHeader)
	if err != nil {
		setHeaderCapturedData(r.Context(), "", "", nil, nil)
		status := http.StatusBadRequest
		msg := "invalid session token"
		if errors.Is(err, errValidationUnavailable) {
			status = http.StatusBadGateway
			msg = "authentication service unavailable"
		}
		http.Error(w, msg, status)
		return true
	}

	if !result.Valid {
		setHeaderCapturedData(r.Context(), result.UserID, result.UserEmail, result.Groups, result.GroupNames)
		http.Error(w, "Unauthorized", http.StatusUnauthorized)
		return true
	}

	setSessionCookie(w, token, config.SessionExpiration)
	if cd := proxy.CapturedDataFromContext(r.Context()); cd != nil {
		cd.SetUserID(result.UserID)
		cd.SetUserEmail(result.UserEmail)
		cd.SetUserGroups(result.Groups)
		cd.SetUserGroupNames(result.GroupNames)
		cd.SetAuthMethod(auth.MethodHeader.String())
	}

View on GitHub (pinned to 93e97f4bf1)