title: Java Spring Boot - Change the Port of Actuator Health Endpoint to a Custom Port
body: <p>I have a Java Spring Boot Application, which is currently running on <a href="http://localhost:8080" rel="noreferrer">http://localhost:8080</a>. I will be containerising this application to be deployed in Kubernetes. For this I have enabled the <code>actuator health</code> endpoint by adding the following to the <code>pom.xml</code> file.</p>
  
  <pre><code>&lt;!-- Spring boot actuator to expose metrics endpoint --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Now, the application Health Endpoint works successfully on <a href="http://localhost:8080/actuator/health" rel="noreferrer">http://localhost:8080/actuator/health</a> endpoint. I wish to change the PORT of the <strong>Health Endpoint URL to be 8081</strong>. <em>(This is to ensure that I can expose 8080 port to the public and expose 8081 port only to the load balancer. This is a personal preference)</em></p>
  
  <p>How can I change the port of the <strong>Health Endpoint</strong> so that the health endpoint URL becomes <a href="http://localhost:8081/actuator/health" rel="noreferrer">http://localhost:8081/actuator/health</a>, and the application runs on <a href="http://localhost:8080/" rel="noreferrer">http://localhost:8080/</a>.</p>