79326115

Date: 2025-01-03 10:15:00
Score: 0.5
Natty:
Report link

I do not know if you run MSSQL in docker or not, but I run into the same strange error when starting Spring Boot Rest Application on the Windows host machine with MSSQL DB on the same machine on WSL in docker.

My connection string looks like "jdbc:sqlserver://localhost:1433;encrypt=false"

And database connection worked fine just until I run my REST API application. Then I get the following error:

250103 115050.433[main] SQLServerConnection - ConnectionID:1 ClientConnectionId: f9c5c414-da5f-471b-9fe8-1ecb603a7d34 Prelogin error: host localhost port 1433 Error reading prelogin response: Connection reset ClientConnectionId:f9c5c414-da5f-471b-9fe8-1ecb603a7d34
250103 115051.437[main] HikariPool - HikariPool-1 - Exception during pool initialization.
com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientConnectionId:f9c5c414-da5f-471b-9fe8-1ecb603a7d34
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:4026) ~[mssql-jdbc-12.4.2.jre11.jar:?]

And from now, no one DB client can connect to this database via 'localhost:1433' until I restart wsl via "wsl --shutdown".

I don't know exactly what problem is, it seems like Spring Boot WEB server localhost binding somehow disturbs WSL network routing. But the solution was very simple: You better should use WSL network address to connect to containers inside WSL docker. This address can be obtained in WSL console via:

hostname -I

172.27.30.136 172.17.0.1

Now this connection string will work: "jdbc:sqlserver://172.27.30.136:1433;encrypt=false"

Reasons:
  • RegEx Blacklisted phrase (1): I get the following error
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Sergei Dmitriev