How do you fix the Whitelabel Error Page in a Spring Boot application?

The Whitelabel Error Page is Spring Boot's default error page that appears when an exception occurs and no custom error handling mechanism is configured. It is commonly seen for issues such as incorrect URL mappings, missing resources, or unhandled exceptions.

Key Points

Example

Suppose a user accesses

http://localhost:8080/products

But the application only contains

@GetMapping("/product")

Since no matching endpoint exists, Spring Boot displays the Whitelabel Error Page with HTTP 404 status.

Common Causes and Solutions

1. Invalid URL Mapping

Problem

Solution

Example

@RestController
@RequestMapping("/users")
public class UserController {

    @GetMapping("/{id}")
    public User getUser() {
        return user;
    }
}

2. Missing Controller Annotation

Problem

Solution

@Controller
or
@RestController

3. Unhandled Exceptions

Problem

Solution

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public ResponseEntity<String> handleException(
            Exception ex) {
        return ResponseEntity
                .status(HttpStatus.INTERNAL_SERVER_ERROR)
                .body("Something went wrong.");
    }
}

4. Missing View Template

Problem

Example

Controller returns

return "home";

But

home.html

is missing from templates folder.

Solution

5. Disable Whitelabel Error Page

Configuration

server.error.whitelabel.enabled=false

This disables the default Spring Boot error page.

6. Create Custom Error Page

Create

src/main/resources/templates/error.html

Spring Boot automatically displays this page when an error occurs.

Example

404.html
500.html
error.html

Benefits

7. Check Application Logs

Logs often contain the exact reason for the failure.

Common Errors

Real-World Example

User requests

/api/orders/100

Application throws

OrderNotFoundException

Instead of showing the Whitelabel page, the application returns

{

"message": "Order not found",

"status": 404

}

Best Practices

Interview Tip

A concise interview answer is: The Whitelabel Error Page appears when Spring Boot encounters an error and no custom error handling is configured. It is commonly caused by incorrect URL mappings, missing views, or unhandled exceptions. It can be resolved by fixing controller mappings, implementing global exception handling using @ControllerAdvice, and creating custom error pages for better user experience.

Last updated: 11 November 2026

Previous question: Can we override or replace the Embedded Tomcat server in Spring Boot?

Next question: How can you implement pagination in a Spring Boot application?

More Spring Boot - Level II interview questions

All Spring Boot - Level II questions