How to connect to the H2 Console from the Browser

In this short article, we will learn how you can connect to the H2 Database, which is running in TCP mode, using the Connection Page available from the Browser Web application.

Firstly, in order to connect to an H2 Database from an external process you need to start H2 in TCP Mode. The following article is a step-by-step guide to start up and configure the H2 Database: H2 Database Tutorial and expert Tips

Then, in order to connect to the H2 DB all you need to know is the webPort attribute which is part of your start-up script. For example:

java -cp ./h2-2.0.202.jar -tcp -ifNotExists -webPort 9080 -webSSL

In the above example, we have explicitly set the webPort to port 9080. Therefore, you can access the H2 Console at: http://localhost:9080

On the other hand, your startup script might just use default values as in the following example

java -cp h2-2.2.224.jar -tcp -web -tcpAllowOthers -ifNotExists

Then, the default Web port you should use is port 8082. Therefore, you should use http://localhost:8082 . See the following example:

how to connect to H2 DB from the browser

If you don’t remember the default value for the webport it’s quite simple to find it. Just do a netstat against the ProcessId of the H2 database:

netstat -tulpn | grep 1754

tcp6       0      0 :::8082                 :::*                    LISTEN      1754/java           
tcp6       0      0 :::9092                 :::*                    LISTEN      1754/java    

As you can see from the above command line, two ports are actively listening:

  • Port 8082 for http connections
  • Port 9092 for https connections


In this article we have discussed how to connect to the H2 Database when running in TCP mode. We have learnt that, by default, H2 DB uses the Port 8082 to allow HTTP Connections from the Browser interface