Looking at https://docs.docker.com/desktop/networking/ it says

I want to connect from a container to a service on the host The host has a changing IP address, or none if you have no network access. We recommend that you connect to the special DNS name host.docker.internal which resolves to the internal IP address used by the host.

When I try this I get "The remote name could not be resolved".

I found this open issue which has a script to map the network gateway port to the host.docker.internal but this just results in "Unable to connect to the remote server".

  • Seem to recall having a similar issue a while back. Please can you try running the following on host machine CMD => hostname. Then using the result. May 24, 2023 at 8:51
  • Running the following what? May 25, 2023 at 23:11
  • 1
    If you open command prompt and type 'hostname' it will output a value for for your computer name like 'dean-desktop-abc'. I was then able to use that as domain, when calling host machine from within docker container. May 26, 2023 at 5:22
  • @DeanOBrien that hostname trick is a gamechanger. Works perfectly. Thank you. Oct 24, 2023 at 21:11

2 Answers 2


I faced the same issue. host.docker.internal is available on identity, solr, but is not available on cm, sql containers.

You have a few options:

  1. You can use ngrok
  2. You can update your container manually by running this script:
# host.docker.internal is not available on CM, so we need to add it manually
$containerId = docker ps --filter ancestor=jss_astro-xm1-cm --format "{{.ID}}"
$ip = Get-NetIPAddress | Where-Object -FilterScript {$_.IPAddress.StartsWith("192")}
$ipAddress = $ip.IPAddress
Write-Host "Adding DNS record to container $containerId. Host: host.docker.internal. IP: $ipAddress"
$command = "'$ipAddress host.docker.internal' | Out-File -Append -Encoding ASCII -FilePath '$($Env:windir)\system32\drivers\etc\hosts'"
docker exec -it $containerId powershell $command

This script will add a record to the CM container hosts file. And point host.docker.internal to your host IP address.

P.S. I expected that it should be fixed in Docker 4.19, according to release notes: "Reverted to fully patching etc/hosts on Windows (includes host.docker.internal and gateway.docker.internal again). For WSL, this behavior is controlled by a new setting in the General tab. Fixes docker/for-win#13388 and docker/for-win#13398."

But the issue is still there. And it requires deeper investigation: why does it work in the Identity container but fail on CM?


Instead of modifying the containers hosts files, you should be able to just reference your docker host name directly. In my case, I wanted to set my CM Server side rendering engine endpoint URL to point to my Next.JS site which was running on my docker host machine.

Start by running this on your host machine:


Then take that value and updat the value of that field to:


This should save you from future issues in case your Docker host machine IP changes due to usage of VPNs/etc.

This will also work, but it may stop working if/when your Docker host IP changes:


You can also experiment with this Docker setting, although in my experience, it doesn't work with some Windows containers.

docker setting for hosts file mod

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.