MS SQL Host unreachable from docker instance

Hi,

I set up metabase with docker for initial testing, so it still uses the H2.

I cannot connect to a SQL Server instance over the network.
It says:

The TCP/IP connection to the host xx.xx.xx.xx, port 1433 has failed. Error: "Host is unreachable (Host unreachable). Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".

I CAN connect to this specific host with sql server management studio and other tools.
The strange thing: When I try to connect to a sql server instance on my local machine (192.168....) it works.

Any ideas?

Thanks
Sascha

{
"browser-info": {
"language": "de",
"platform": "Win32",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.26",
"vendor": "Google Inc."
},
"system-info": {
"file.encoding": "UTF-8",
"java.runtime.name": "OpenJDK Runtime Environment",
"java.runtime.version": "11.0.16.1+1",
"java.vendor": "Eclipse Adoptium",
"java.vendor.url": "https://adoptium.net/",
"java.version": "11.0.16.1",
"java.vm.name": "OpenJDK 64-Bit Server VM",
"java.vm.version": "11.0.16.1+1",
"os.name": "Linux",
"os.version": "5.10.102.1-microsoft-standard-WSL2",
"user.language": "en",
"user.timezone": "GMT"
},
"metabase-info": {
"databases": [
"h2",
"sqlserver",
"googleanalytics"
],
"hosting-env": "unknown",
"application-database": "h2",
"application-database-details": {
"database": {
"name": "H2",
"version": "1.4.197 (2018-03-18)"
},
"jdbc-driver": {
"name": "H2 JDBC Driver",
"version": "1.4.197 (2018-03-18)"
}
},
"run-mode": "prod",
"version": {
"date": "2022-10-17",
"tag": "v0.44.5",
"branch": "release-x.44.x",
"hash": "29fab4d"
},
"settings": {
"report-timezone": null
}
}
}

1 Like

Hi @SaschaW
You are running Metabase inside of a container, so if you are trying to access the host, then you need to reference the right IP https://stackoverflow.com/questions/28056522/access-host-database-from-a-docker-container and network https://docs.docker.com/network/

If you are not familiar with Docker (and WSL2), then it's likely easier to use JAR on WSL2, so there's one less containerization going on.

And make sure that you don't have firewalls blocking traffic.

I would say I'm very familiar with docker :stuck_out_tongue: thats why I am wondering why the outbound traffic behaves different... And the case that is not working is with the ip of another machine, that shouldn't be affected by any docker networking stuff (bridge network). But I can try the jar within wsl, thanks for that hint!

@SaschaW If you are familiar with Docker, then I guess the "fun" comes from WSL2 or perhaps outgoing firewall in Windows.

i have the exact same issue.

From inside docker i can ping the SQL server. So a connection is there. netcat doesn’t connect.

The strange thing is that Grafana docker used in the same way can connect just fine. Using the “Skip TLS Verify” option and “SQL Server Authentication”

the dBeaver app on Windows 11 on the same machine also works.

Docker Terminal:

/ # ping 169.168.1.12
PING 169.168.1.12 (169.168.1.12): 56 data bytes
64 bytes from 169.168.1.12: seq=0 ttl=63 time=2.794 ms
64 bytes from 169.168.1.12: seq=1 ttl=63 time=3.110 ms
^C
--- 169.168.1.12 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 2.794/2.952/3.110 ms
/ # 
Metabase tried, but couldn't connect
The TCP/IP connection to the host 169.168.1.12, port 1433 has failed. Error: "Connect timed out. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".

How do i switch the SSL Mode to skip?

P.S this is an SQL Express server under SERVER02\SQLEXPRESS but that should not be an issue right?

@Haldi

Perhaps it is a port issue. Try troubleshooting as mentioned here: Trouble connecting to SQL Server · Issue #1854 · metabase/metabase · GitHub

Just the joys of JDBC. ODBC is able to communicate with the SQL Agent to get the port. Your Express server is probably using a different port. Find out what it’s using, then specify the port.