---
title: "Can't reach a Docker container from your Mac: ports and IPs · Kilobat Guides"
url: "https://kilobat.app/guides/docker-container-from-mac"
description: "Connect from macOS to a service in Docker Desktop or OrbStack: publish the port, use localhost, and know when container IP addresses work."
---

Developers

# Cannot reach a Docker container from the Mac

Docker on a Mac runs containers in a Linux virtual machine. To reach a container from macOS, you usually publish a port to localhost.

Applies to: Docker Desktop and OrbStack on current macOS versions. · Checked: 29 October 2026

## Symptoms

- `curl localhost:8080` fails, but the service works inside the container.
- You cannot ping or connect to the container's IP address.
- No `docker0` interface shows on the Mac.
- The service works on Linux but not on the Mac.

## Likely causes

- **The port is not published.** Without `-p`, Docker Desktop does not forward the port to the Mac.
- **Container IPs on Docker Desktop.** Docker's documentation for Docker Desktop says that its bridge network is not reachable from the host.
- **The service listens on 127.0.0.1 in the container.** Then only the container itself can connect to it.
- **A wrong port pair.** In `-p 8080:80`, 8080 is the Mac port and 80 is the container port.

## How to check

1. List the running containers and their published ports.

   ```
   docker ps
   ```

   Output The PORTS column shows pairs such as `0.0.0.0:8080->80/tcp`. No pair means the port is not published.
2. Show the published ports of one container.

   ```
   docker port my-container
   ```
3. Test the service from inside the container, if the image includes wget. A reply means that the service works.

   ```
   docker exec my-container wget -qO- http://localhost:80
   ```
4. See which process on the Mac listens on the port.

   ```
   lsof -nP -iTCP:8080 -sTCP:LISTEN
   ```

## How to fix it

1. Start the container with a published port. The first number is the port on the Mac.

   ```
   docker run -d -p 8080:80 nginx
   ```
2. Connect from the Mac with localhost and the Mac port.

   ```
   curl http://localhost:8080
   ```
3. Make the service in the container listen on 0.0.0.0, not 127.0.0.1. See its own documentation for the setting.
4. If the Mac port is in use, choose another Mac port. See [Port already in use on a Mac](https://kilobat.app/guides/port-already-in-use).
5. With OrbStack, you can also use the container's IP address or its `container-name.orb.local` name.

## With Kilobat

1. Kilobat's checks run on the Mac. Use `--context container` when the failing code runs in a container. The report then ends with a command to run there.

   ```
   kilobat why http://localhost:8080 --context container
   ```

## Questions

**Why can I not ping a container on Docker Desktop?**

Docker's documentation says that Docker Desktop cannot route traffic to Linux containers from the Mac. Publish a port instead.

**Does OrbStack work differently?**

Yes. OrbStack's documentation says that you can connect to containers by IP address and by `.orb.local` names from the Mac.

## Sources

- [Docker Docs: Explore networking how-tos on Docker Desktop](https://docs.docker.com/desktop/features/networking/networking-how-tos/)
- [Docker Docs: Networking on Docker Desktop](https://docs.docker.com/desktop/features/networking/)
- [OrbStack Docs: Container networking](https://docs.orbstack.dev/docker/network)
- lsof(8), man page installed with macOS 27.2

Sources checked on 29 October 2026. Man pages are the ones installed with macOS; open one with `man <name>` in Terminal.

## Related guides

- [A container cannot reach localhost on the Mac](https://kilobat.app/guides/localhost-from-container): Each container has its own network stack.
- [Port already in use on a Mac](https://kilobat.app/guides/port-already-in-use): Only one process can listen on a TCP port and address.
- [Find why one site or API won't connect](https://kilobat.app/guides/recipes/why-cant-it-connect): When the internet works but one address fails, Kilobat checks each layer in turn.
- [Port 5000 or 7000 is in use on a Mac: AirPlay Receiver](https://kilobat.app/guides/airplay-receiver-port-5000): Apple lists TCP ports 5000 and 7000 for AirPlay.
