question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't connect to localhost using host.docker.internal

See original GitHub issue

Actual Behavior

Trying to connect to azure mssql within docker container. Bitvise client is running on windows host, bound to all interfaces (0.0.0.0) on port 1435. Trying to access it using tsql with host parameter host.docker.internal port 1435 but times out after +/- 2 minutes, bitvise logs show no communication attempts. If i try to connect directly to the database IP address the connection is established but access is denied as per server access rules (IP address not allowed to connect).

Steps to Reproduce

Install Rancher Desktop, updated to 1.2.1.

Built container with net=host or net=bridge or not setting it at all

Run:

  • tsql -H host.docker.internal -p 1435 -U [user] -P [password] -D [database]
  • tsql -H host.rancher-desktop.internal -p 1435 -U [user] -P [password] -D [database]
  • tsql -H host.rancher-desktop.internal -p 1435 -U [user] -P [password] -D [database]
  • tsql -H 127.0.1.1 -p 1435 -U [user] -P [password] -D [database]

WSL2 is used

Result

tsql times out or refuses to connect.

Expected Behavior

Login to the database server and query databases

Additional Information

Untitled

Routing info inside Rancher Desktop host

Untitled

Rancher Desktop Version

1.2.1

Rancher Desktop K8s Version

1.22.7

Which container runtime are you using?

moby (docker cli)

What operating system are you using?

Windows

Operating System / Build Version

Windows 10 Enterprise, build 19044

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

No response

Windows User Only

Custom defined VPN

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
janduboiscommented, May 3, 2022

disabling that rule has me able to connect from RD to the host again

@dougbreaux Thanks for confirming that this was a local config issue. The new firewall rule proposed by @Nino-K seems to fix the problem for everyone who has responded so far.

I’m going to hide your earlier messages as “outdated” to prevent confusing users who find this issue via a Google search.

BTW, I find that sometimes when I stop and start a container, the host.docker.internal hostname is gone from hosts.

Please file a separate issue for unrelated problems!


I’ll leave this bug open for now until we have figured out if we want to add the firewall rule to the installer or some other way to make it easier for users to enable it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

From inside of a Docker container, how do I connect to the ...
Use --network="host" in your docker run command, then 127.0.0.1 in your docker container will point to your docker host. Note: This mode only...
Read more >
How to reach localhost on host from docker container?
To connect to your host's localhost from within a container use 172.17.0.1 (as you are running on Linux). It would be host.docker.internal ......
Read more >
Trying to access host.docker.internal results in Connection ...
I have tried with the latest version of my channel (Edge); I have uploaded Diagnostics; Diagnostics ID: Expected behavior.
Read more >
How to Connect to Localhost Within a Docker Container
Here's how to access localhost or 127.0.0.1 from within a Docker ... You could replace host.docker.internal with your own string if you ...
Read more >
How to connect to the Docker host from inside a ... - Medium
As of Docker version 18.03, you can use the host.docker.internal hostname to connect to your Docker host from inside a Docker container.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found