H2 database console spring boot Load denied by X-Frame-Options
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
The H2 database is a popular in-memory database for Java applications. One of its notable features is the web-based console, which provides a user-friendly interface for database management. When integrating H2 with a Spring Boot application, developers occasionally encounter the "Load denied by X-Frame-Options" error when attempting to access the console. This article explores this error, its causes, and how to resolve it in a Spring Boot environment.
Understanding X-Frame-Options
The X-Frame-Options
is an HTTP response header used to control whether a browser should be allowed to render a page in a ``<frame>
`,
`<iframe>
`, or
`<object>
``. It is employed as a measure against clickjacking attacks — where malicious sites trick users into clicking on something different from what the user perceives.
The header can take three values:
DENY: Prevents any domain from framing the content.SAMEORIGIN: Allows pages to be framed if both the top-level page and the iframe share the same origin.ALLOW-FROM uri: Permits framing only from a particular URI (not widely supported by modern browsers).
Causes of the Error
When using the H2 console in Spring Boot, the X-Frame-Options error typically arises because of the security settings in the Spring Boot application. By default, Spring Security adds a X-Frame-Options
header with the value DENY
, blocking the console from being accessed inside a frame or iframe.
Technical Example
Here is an example of how this issue might manifest in an H2 database console integration:
Suppose you have a Spring Boot application with the following basic configuration:
- Security Implication: Changing security settings can expose applications to potential risks. Ensure you understand the implications of modifying headers and only allow trusted origins.
- Environment Specific Configuration: If this is an application feature only utilized in development, ensure that these settings are restricted to development environments using active profiles.
Related reading
- H2 Database not found error 90146. H2 database is not created on start
- H2 in-memory database. Table not found
- Hadoop on cassandra database
- Handling asynchronous database queries in node.js and mongodb
- \`Hash\` Function Determination
- `Hash` Password in C? Bcrypt/PBKDF2
- Hadoop NoClassDefFoundError when adding external Jar
- Handling exceptions from Java ExecutorService tasks

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.