You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Podman containers on Windows cannot connect to the host via localhost.
Steps to reproduce the issue
Invoke-WebRequest -Uri http://localhost:5079 | Select-Object StatusCode
# StatusCode# ----------# 200
docker run --rm --network host curlimages/curl -I -X GET http://localhost:5079
# % Total % Received % Xferd Average Speed Time Time Time Current# Dload Upload Total Spent Left Speed# 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0HTTP/1.1 200 OK# 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0# Content-Type: application/json; charset=utf-8# Date: Sat, 23 Nov 2024 13:31:55 GMT# Server: Kestrel# Transfer-Encoding: chunked
podman run --rm --network host curlimages/curl -I -X GET http://localhost:5079
# % Total % Received % Xferd Average Speed Time Time Time Current# Dload Upload Total Spent Left Speed# 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0# curl: (7) Failed to connect to localhost port 5079 after 0 ms: Could not connect to server
Describe the results you received
Podman container cannot connect to a port exposed on the host via localhost.
Describe the results you expected
Podman container can connect to a port exposed on the host via localhost.
podman info output
host:
arch: amd64buildahVersion: 1.38.0cgroupControllers: []cgroupManager: cgroupfscgroupVersion: v1conmon:
package: conmon-2.1.12-2.fc40.x86_64path: /usr/bin/conmonversion: 'conmon version 2.1.12, commit: 'cpuUtilization:
idlePercent: 99.8systemPercent: 0.1userPercent: 0.1cpus: 20databaseBackend: sqlitedistribution:
distribution: fedoravariant: containerversion: "40"eventLogger: journaldfreeLocks: 1991hostname: MyPCidMappings:
gidmap:
- container_id: 0host_id: 1000size: 1
- container_id: 1host_id: 524288size: 65536uidmap:
- container_id: 0host_id: 1000size: 1
- container_id: 1host_id: 524288size: 65536kernel: 5.15.167.4-microsoft-standard-WSL2linkmode: dynamiclogDriver: journaldmemFree: 15142686720memTotal: 16626593792networkBackend: netavarknetworkBackendInfo:
backend: netavarkdns:
package: aardvark-dns-1.12.2-2.fc40.x86_64path: /usr/libexec/podman/aardvark-dnsversion: aardvark-dns 1.12.2package: netavark-1.12.2-1.fc40.x86_64path: /usr/libexec/podman/netavarkversion: netavark 1.12.2ociRuntime:
name: crunpackage: crun-1.18.2-1.fc40.x86_64path: /usr/bin/crunversion: |- crun version 1.18.2 commit: 00ab38af875ddd0d1a8226addda52e1de18339b5 rundir: /run/user/1000/crun spec: 1.0.0 +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJLos: linuxpasta:
executable: /usr/bin/pastapackage: passt-0^20241030.gee7d0b6-1.fc40.x86_64version: | pasta 0^20241030.gee7d0b6-1.fc40.x86_64 Copyright Red Hat GNU General Public License, version 2 or later <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.remoteSocket:
exists: truepath: unix:///run/user/1000/podman/podman.sockrootlessNetworkCmd: pastasecurity:
apparmorEnabled: falsecapabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOTrootless: trueseccompEnabled: trueseccompProfilePath: /usr/share/containers/seccomp.jsonselinuxEnabled: falseserviceIsRemote: trueslirp4netns:
executable: ""package: ""version: ""swapFree: 4294967296swapTotal: 4294967296uptime: 0h 30m 26.00svariant: ""plugins:
authorization: nulllog:
- k8s-file
- none
- passthrough
- journaldnetwork:
- bridge
- macvlan
- ipvlanvolume:
- localregistries:
search:
- docker.iostore:
configFile: /home/user/.config/containers/storage.confcontainerStore:
number: 45paused: 0running: 0stopped: 45graphDriverName: overlaygraphOptions: {}graphRoot: /home/user/.local/share/containers/storagegraphRootAllocated: 1081101176832graphRootUsed: 9572601856graphStatus:
Backing Filesystem: extfsNative Overlay Diff: "true"Supports d_type: "true"Supports shifting: "false"Supports volatile: "true"Using metacopy: "false"imageCopyTmpDir: /var/tmpimageStore:
number: 21runRoot: /run/user/1000/containerstransientStore: falsevolumePath: /home/user/.local/share/containers/storage/volumesversion:
APIVersion: 5.3.0Built: 1731456000BuiltTime: Wed Nov 13 01:00:00 2024GitCommit: ""GoVersion: go1.22.7Os: linuxOsArch: linux/amd64Version: 5.3.0Version: 5.3.0
I stepped somehow in a similar issue. First of all I think you need to use host.docker.internal / host.containers.internal instead of localhost.
I noticed a difference between Windows and Linux here. On Windows the host.docker.internal / host.containers.internal IPs address the WSL2 VM in background. Thus I am using the following batch snippet to workaround the problem (based on [1]).
SETWSLCMD=wsl -d podman-machine-default -u root
FOR /F %%iIN ('powershell "Get-NetIpAddress | where { $_.InterfaceAlias -Like '*WSL*' -and $_.AddressFamily -EQ 'IPv4' } |select -ExpandProperty IPAddress"') DOsetWSLIP=%%i%WSLCMD% sh -c "sed -i '/^host_containers_internal_ip/d' /etc/containers/containers.conf"%WSLCMD% sh -c "sed -i '/\[containers\]/a host_containers_internal_ip = \"%WSLIP%\"' /etc/containers/containers.conf"
In cleartext - set the host_containers_internal_ip setting to match the WSL bridge network ip from windows.
First of all I think you need to use host.docker.internal / host.containers.internal instead of localhost.
Thank you for your suggestion, but unfortunately, I have to use localhost as it's a convention in our setup. All our services have dev/local configurations where URLs to other services use localhost, so developers can run everything locally in IDE/Docker/Podman, and the services communicate with each other via localhost.
Issue Description
Podman containers on Windows cannot connect to the host via localhost.
Steps to reproduce the issue
Describe the results you received
Podman container cannot connect to a port exposed on the host via localhost.
Describe the results you expected
Podman container can connect to a port exposed on the host via localhost.
podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
No
Additional environment details
Additional information
Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting
The text was updated successfully, but these errors were encountered: