Failed to make a request from docker to the host machine

I need to make a request from a docker container to the host machine.

Example request look like this:

/ # apk add curl
(1/10) Installing ca-certificates (20240226-r0)
(2/10) Installing brotli-libs (1.1.0-r2)
(3/10) Installing c-ares (1.28.1-r0)
(4/10) Installing libunistring (1.2-r0)
(5/10) Installing libidn2 (2.3.7-r0)
(6/10) Installing nghttp2-libs (1.62.1-r0)
(7/10) Installing libpsl (0.21.5-r1)
(8/10) Installing zstd-libs (1.5.6-r0)
(9/10) Installing libcurl (8.8.0-r0)
(10/10) Installing curl (8.8.0-r0)
Executing busybox-1.36.1-r29.trigger
Executing ca-certificates-20240226-r0.trigger
OK: 14 MiB in 24 packages
/ # curl http://host.docker.internal:3000
curl: (7) Failed to connect to host.docker.internal port 3000 after 3 ms: Couldn't connect to server
/ # 

In the browser http://host.docker.internal:3000 opens normally. Why does this happen and how to avoid it?


OS: macOS Sonoma


# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
## 		localhost	broadcasthost
::1             localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:		kubernetes.docker.internal		host.docker.internal
::1				host.docker.internal
# End of section inside a Docker container is the internal localhost, not from the host.