Spring Boot Actuator is not working because the spring boot actuator dependency is incorrect or the actuator isn’t configured properly in the application.properties file. If the spring boot starter actuator is not configured, endpoints like health, info, shutdown, refresh, env, and metrics may not work.

Spring Boot Actuator is a sub-project in the Spring Boot Framework that help us to monitor and manage the Spring Boot application. Spring boot actuators supports HTTP and JMX endpoints to manage and monitor. Actuator contains the endpoints, metrics and audits.



Spring Boot Actuator Not Working

If the spring boot actuator endpoints are invoked in the spring boot application, the url will show error. The actuator endpoints may not be working or the page returns with error.

Endpoint

http://localhost:8080/actuator/

Error

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sun Oct 31 19:01:16 IST 2021
There was an unexpected error (type=Not Found, status=404).


Solution 1

The spring boot actuator endpoint’s url could be incorrect or invalid. Check the url and make the necessary changes. The spring boot actuator endpoint url contains “/actuator”. The actuator must be included in the url for it to work. It’s possible you’re calling the spring boot actuator endpoint without the “/actuator” parameter.

Incorrect url

http://localhost:8080/health

Correct url

http://localhost:8080/actuator/health


Solution 2

Dependencies for spring boot actuators may not be added to the pom.xml file. Spring boot actuator requires the spring-boot-starter-actuator and spring-boot-starter-web dependencies to work properly. Add any dependencies that aren’t configured in the pom.xml file to the pom.xml file. All actuator endpoints are provided in the spring-boot-starter-actuator dependency. The actuator endpoints in the spring boot application are invoked using the spring-boot-starter-web dependency.

pom.xml

.........
	<dependencies>
.........
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
.........
	</dependencies>
........


Solution 3

You can change the spring boot actuator port in the application.properties file. If the actuator url is executed with a port other than the configured port, the spring boot actuator endpoints will not work. In the application.properties file, check at the actuator port configuration. Using the right port, call the endpoint url.

application.properties

management.server.port=8081


Solution 4

In the application.properties file, you can change the spring boot actuator url. The actuator endpoint url in the application.properties file may be specified differently for security reasons.  In the application.properties file, double-check the endpoint url. Invoke the actuator endpoint url as specified in the file’s configuration.

application.properties

management.endpoints.web.base-path=/mgmt

endpoint url

http://localhost:8080/mgmt/


Solution 5

If none of the preceding solutions work, delete or comment all actuator-related configurations in the application. properties. In the application, add the following configuration. All endpoints in the spring boot actuator will be enabled if these properties are set. use the spring boot actuator’s default endpoint url. Ensure that the page’s endpoints are listed.

application.properties

management.endpoints.web.exposure.include=*

endpoint url

http://localhost:8080/actuator/


Solution 6

The spring boot actuator’s shutdown endpoint is disabled by default. Add the shutdown endpoint configuration to the application.properties file to enable it. The POST method is used to access the /shutdown endpoint. In the browser, it will not work. Invoke the /shutdown endpoint in the spring boot actuator using the postman or curl commands.

application.properties

management.endpoint.shutdown.enabled=true

curl command

curl -X POST http://localhost:8080/actuator/shutdown


Solution 7

Spring boot actuators can be configured to activate specified endpoints by default. It is possible to enable the use of the list of needed endpoints. It’s possible that the endpoints may not be visible on the web. If you use the endpoint url, the web module might not be able to serve the page to you.

Make sure the following settings are in the application.properties file. The first step is to turn off all of the endpoints. The relevant endpoints will be enabled by the second configuration. In the third setup, the required endpoint will be seen in the http browser.

application.properties

management.endpoints.enabled-by-default=false
management.endpoint.health.enabled=true
management.endpoints.web.exposure.include=health



Leave a Reply