title: H2 Database connection timeout with new computer
body: <p>I'm using two H2 databases in my Java projects. Recently, I changed my computer and since then I have no problem with connecting to one of those databases using my Java code but problems with the other one. It's exactly the same code (up to PATH_TO_DATABASE) I use to start the connection:</p>
  
  <pre><code>import java.sql.DriverManager;
  import java.sql.SQLException;
  
  public class DatabaseConfig {
  
      private static java.sql.Connection connection;
  
      public static void init() {
          if (connection == null) {
              try {
                  connection = DriverManager.getConnection("jdbc:h2:tcp://192.168.178.50:9092/C:/Users/PATH_TO_DATABASE", "USER", "PW");
              } catch (SQLException e) {
                  System.err.println("SQLException");
                  e.printStackTrace();
                  System.exit(0);
              }
          }
      }
  
      [...]
  }
  </code></pre>
  
  <p>This is the stack trace I get:</p>
  
  <pre><code>SQLException
  org.h2.jdbc.JdbcSQLException: Connection is broken: "java.net.SocketTimeoutException: connect timed out: 192.168.178.21:9092" [90067-196]
      at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
      at org.h2.message.DbException.get(DbException.java:168)
      at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:457)
      at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:334)
      at org.h2.jdbc.JdbcConnection.&lt;init&gt;(JdbcConnection.java:116)
      at org.h2.jdbc.JdbcConnection.&lt;init&gt;(JdbcConnection.java:100)
      at org.h2.Driver.connect(Driver.java:69)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at data.DatabaseConfig.init(DatabaseConfig.java:20)
      ...
  Caused by: java.net.SocketTimeoutException: connect timed out
      at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
      at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
      at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
      at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
      at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
      at java.net.PlainSocketImpl.connect(Unknown Source)
      at java.net.SocksSocketImpl.connect(Unknown Source)
      at java.net.Socket.connect(Unknown Source)
      at org.h2.util.NetUtils.createSocket(NetUtils.java:103)
      at org.h2.util.NetUtils.createSocket(NetUtils.java:83)
      at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:115)
      at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:453)
      ... 8 more
  </code></pre>
  
  <p>Using the web interface I can connect to both databases easily.</p>
  
  <p>I'm a little bit lost here since I can't figure out what's going wrong with one of the databases. The strange thing is that everything works fine with the other database.</p>
  
  <p><strong>EDIT:</strong> I just realized that the IP address in the error message is different from the one in the code (192.168.178.21:9092 vs. 192.168.178.50:9092). Maybe this is th ereason of the error. The one in the code is the correct IP address. Why do I get a different one in the error message? Is that the reason of my problem?</p>