Spring Actuator Endpoints Returning 401
Spring Actuator endpoints (/actuator/metrics, /actuator/health) return 401 Unauthorized. Metrics and health checks are blocked.
Security configuration restricts actuator access inappropriately.
Error Messages You Might See
Common Causes
- Authentication required for actuator endpoints
- ROLE not matching actuator security rule
- Actuator endpoints not exposed in application.yml
- Too strict SecurityFilterChain
- CSRF token missing for POST requests
How to Fix It
In application.yml: management.endpoints.web.exposure.include=health,metrics. In SecurityConfig: permitAll() for /actuator/** or httpBasic(). Use @EnableSpringDataWebSupport for proper role checking. For development, disable auth: management.security.enabled=false (NOT for production).
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
Which endpoints should be public?
/actuator/health is usually public. /actuator/metrics usually needs auth
How do I expose all actuator endpoints?
management.endpoints.web.exposure.include=* (only for internal apps!)