Access host machine running web service from container on Arch linux #25120
-
Hello, Sorry for bringing this up, but I have an issue accessing my host machine's web server from a container. So, Podman version 5.3.2. I have launched a simple web service on http://localhost:5042 and created a container for it on http://localhost:64923. [r@r-82b1 ~]$ podman run -it --name AlpineWithCurl alpine:latest
/ # apk add curl
/ # curl -v http://host.containers.internal:64923/
* Host host.containers.internal:64923 was resolved.
* IPv6: (none)
* IPv4: 169.254.1.2
* Trying 169.254.1.2:64923...
* Connected to host.containers.internal (169.254.1.2) port 64923
* using HTTP/1.x
> GET / HTTP/1.1
> Host: host.containers.internal:64923
> User-Agent: curl/8.11.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=utf-8
< Date: Sat, 25 Jan 2025 16:44:35 GMT
< Server: Kestrel
< Transfer-Encoding: chunked
<
* Connection #0 to host host.containers.internal left intact
/ # curl -v http://host.containers.internal:5042
* Host host.containers.internal:5042 was resolved.
* IPv6: (none)
* IPv4: 169.254.1.2
* Trying 169.254.1.2:5042...
* connect to 169.254.1.2 port 5042 from 192.168.50.17 port 42592 failed: Connection refused
* Failed to connect to host.containers.internal port 5042 after 0 ms: Could not connect to server
* closing connection #0
curl: (7) Failed to connect to host.containers.internal port 5042 after 0 ms: Could not connect to server
/ # cat /etc/host
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 r-82b1
169.254.1.2 host.containers.internal host.docker.internal
192.168.50.17 e7eeff0a106e AlpineWithCurl Is there anything I could check and try out? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Update - tried with disabling firewall and no luck. |
Beta Was this translation helpful? Give feedback.
-
Connecting to the host's localhost is not allowed by default. You could use one of the pasta options I wrote some examples of how to use rootless Podman with the pasta network driver to connect to the host: Outbound TCP/UDP connections to the host's localhost Outbound TCP/UDP connections to the host's main network interface (e.g eth0) |
Beta Was this translation helpful? Give feedback.
Connecting to the host's localhost is not allowed by default.
You could use one of the pasta options
--map-gw
,--map-host-loopback
or--tcp-ns
(-T
).I wrote some examples of how to use rootless Podman with the pasta network driver to connect to the host:
Outbound TCP/UDP connections to the host's localhost
Outbound TCP/UDP connections to the host's main network interface (e.g eth0)