The Whitelabel Error Page is what Spring Boot shows when a request fails and nothing else has claimed the error. It is not itself the problem; it is the messenger. The status code and the message printed on it say what went wrong, and in nearly every case it is one of four things: no handler matched the URL, a view could not be found, an exception was thrown in a controller, or the request was blocked before reaching one. This article covers reading the page, fixing each cause, and replacing the page with something suitable for users.
Reading the page#
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Sep 08 10:14:02 BST 2026
There was an unexpected error (type=Not Found, status=404).
The status is the diagnosis. 404 means Spring received the request and found no controller for it. 500 means a controller ran and threw. 403 means security rejected it. 405 means the path exists but not for that HTTP method. The message may be blank in production, because Boot hides details by default; the console log has the full story either way.
404: no mapping#
The most common Whitelabel by far. Check, in order:
- The controller is not a bean. Missing
@RestControlleror@Controller, or the class is in a package outside the application’s scan. Move it under the main class’s package, or add@ComponentScan. - The path does not match. A class-level
@RequestMapping("/api")plus a method-level@GetMapping("/items")serves/api/items, not/items. Trailing slashes are not matched by default in recent Spring versions. - Context path or port.
server.servlet.context-path=/appputs everything under/app. Checkserver.porttoo. - The wrong HTTP method. A
@PostMappinghit with GET gives 405, but a form or a browser can turn it into a 404-looking failure. Check the method in the log.
logging.level.org.springframework.web=DEBUG
With that setting, startup prints every mapped route, and each request logs which handler it matched or that none did. It answers the 404 question directly.
500: your code threw#
A 500 on the Whitelabel page always has a stack trace in the console. Read it; the Whitelabel page has nothing to add. Common ones: a NullPointerException in the controller, a database query failing, a JSON body that could not be parsed into the parameter type. Fix the exception, and consider a @ControllerAdvice so that expected failures return a proper status instead of 500.
Views and templates#
Error resolving template [home], template might not exist or might not be accessible
A @Controller (not @RestController) returned the string “home” and Spring looked for a template to render. Either:
- You meant to return data, not a view. Use
@RestControlleror add@ResponseBody. - No template engine is on the classpath. Add the Thymeleaf starter.
- The file is missing or misnamed: it must be
src/main/resources/templates/home.html.
Static files — CSS, images, plain HTML — go under src/main/resources/static and are served at the root. A 404 for /style.css means it is not in that folder, or the build did not copy resources.
403 and 401#
With Spring Security on the classpath, every endpoint requires authentication by default. An unauthenticated browser request is redirected to a login page; an API call gets a 401 or 403, sometimes rendered as Whitelabel. Configure which paths are public in a SecurityFilterChain, and check for CSRF on POST requests from non-browser clients.
Replacing the page#
For a web application, add your own error templates. Spring Boot looks for them by status code:
src/main/resources/templates/error/404.html
src/main/resources/templates/error/500.html
src/main/resources/templates/error.html # fallback for everything else
Or under static/error/ for plain HTML. The templates receive status, error, message and path as model attributes. Nothing else to configure; the presence of the files is enough.
For an API, you want JSON, not a page. Spring Boot returns JSON automatically when the client sends Accept: application/json, and Boot 3 formats it as Problem Details when enabled:
spring.mvc.problemdetails.enabled=true
For full control, a @ControllerAdvice with @ExceptionHandler methods maps your exceptions to responses and bypasses the error page entirely.
@RestControllerAdvice
class ApiErrors {
@ExceptionHandler(NotFoundException.class)
ProblemDetail notFound(NotFoundException e) {
return ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND, e.getMessage());
}
}
Turning it off#
server.error.whitelabel.enabled=false
This removes the Whitelabel page and lets the servlet container’s own error page show, which is uglier. Only do it if you are providing your own error handling; otherwise, replace rather than disable.
Showing more in development#
server.error.include-message=always
server.error.include-binding-errors=always
server.error.include-stacktrace=on_param
Puts the exception message on the page and in the JSON, and adds the stack trace when ?trace=true is on the URL. Keep these in a development profile; on a public site the message can leak internals.
Questions people ask#
Why does the page say there is no mapping for /error?
Because Spring Boot forwards failed requests to /error internally and, if you have not defined a handler for it, renders its default. It is informational, not the cause.
The page appears for every URL including the root.
No controller maps /, or none is being scanned. Add a mapping for the root, or an index.html under static.
Can I return a different status for my own exceptions?
Yes: @ResponseStatus(HttpStatus.NOT_FOUND) on the exception class, or an @ExceptionHandler in a controller advice.
Why do I get JSON in Postman but Whitelabel in the browser?
Content negotiation. Browsers ask for HTML, Postman for JSON, and Spring Boot renders the error differently for each. Both come from the same failure.
Where to go next#
- Returning proper error messages from Spring Boot — ControllerAdvice in depth.
- “Error creating bean with name” — when the application does not start at all.
- Java web development — controllers, views and static files.