Port Binding on macOS
2026-11-22
Introduction
Binding network ports on macOS has some unexpected behavior compared to traditional Unix systems. This post explains the differences and their security implications.
Traditional Unix Behavior
On Unix systems, binding to privileged ports below 1024 requires root privileges. This restriction exists because system services typically bind to these ports. The assumption is that only an administrator can start such services, establishing implicit trust. Regular users can only bind to ports 1024 and above.
macOS Since Mojave
Starting with macOS Mojave from 2018, Apple changed this behavior in a non-obvious way. Binding to any port on all network interfaces works without root privileges. However, binding a privileged port to a specific interface like localhost requires root. This creates an inconsistent permission model that catches many developers off guard.
The Ollama Example
A discussion about exposed Ollama inference endpoints illustrates the broader risk. Ollama binds to 127.0.0.1 by default, which is a secure configuration. On macOS, non-root users encountering localhost binding failures may remove the interface restriction as a workaround. This results in listening on all network interfaces, often without users realizing the exposure.
References
- Unix privileged ports explanation: Unix Stack Exchange
- macOS Mojave port binding discussion: Hacker News
- Ollama endpoint exposure issue: Hacker News
- Apple Developer Forums thread: Apple Developer
- Podman issue tracker: GitHub