Guides · published

How to diagnose a local LLM port conflict on Mac

Check which process is listening on your chosen port, distinguish an HTTP response from a connection failure, and resolve a conflict without stopping an unrelated process.

When a local model server cannot bind its port, or the browser opens an unexpected page, first check the listener. Another process may already own that address. A running HTTP service also does not necessarily mean that your model has loaded.

This guide separates three questions: is a process listening, does HTTP answer, and is it the service you intended to start? It does not test model quality, inference speed or memory fit.

1. Inspect the port from your startup command

The example uses port 8080. Replace it if your server uses a different port, then run:

port=8080
lsof -nP -iTCP:"$port" -sTCP:LISTEN

Look at COMMAND, PID and the address in NAME. A row ending in 127.0.0.1:8080 (LISTEN) identifies a listener on that IPv4 loopback address. A wildcard address is different; do not assume it is restricted to localhost. A process name alone is not proof that it loaded the intended model.

No rows means this command did not report a visible TCP listener for that port. Check the startup terminal for an error, a different port or a process that has already exited. Permissions can limit process visibility; do not treat an empty result as a security audit.

2. Ask whether HTTP answers

Use the same port and match the address family shown by lsof. For a listener on IPv4 loopback (127.0.0.1), set:

server_url="http://127.0.0.1:$port/"

For an IPv6 loopback listener (::1, often shown as [::1]), use this value instead:

server_url="http://[::1]:$port/"

Then run the request using the value you selected:

curl -sS --connect-timeout 2 --max-time 5 \
  -o /dev/null -w 'HTTP %{http_code}\n' \
  "$server_url"

--connect-timeout limits the connection phase; --max-time bounds the whole request. The body is discarded so a large or unrelated page does not fill your terminal. If your shell uses an HTTP proxy, check its localhost exclusion before interpreting this as a direct local connection.

Result What to check next
An HTTP status such as 200 Something answered. Confirm the owning process and server log before assuming a model is ready.
401 or 403 A service answered but access was rejected. Check that service’s authentication settings.
404 The service answered but this path was not found. Check the intended endpoint.
HTTP 000 with a curl error No HTTP status was received. Read the curl error; a refused connection differs from a timeout.

These are diagnostic steps, not instructions to disable authentication or expose the server beyond loopback. The example does not request redirect following; your local curl configuration can change its defaults.

3. Resolve the conflict deliberately

If the listener is your old server, return to the terminal that started it and stop it there with Control-C, or use the application’s normal stop action. Re-run the listener check before restarting. Do not kill a PID just because it occupies the port; it may belong to another application or task.

If you need to keep both services, choose another port in the new server’s startup command and update the browser URL and API client to match. For a local-only llama.cpp setup, retain the explicit loopback binding described in the Mac startup guide. Changing only the browser URL does not change the server’s listening port.

Once the intended service answers, inspect its model-loading output and perform a small request using its documented API. Only then move on to benchmarking. If loading fails because of memory, use the Mac memory diagnostic guide.

What we tested

On November 4 we started a disposable Python HTTP listener on 127.0.0.1:56444. lsof found it, curl received HTTP 200, and after shutdown curl returned exit code 7 with HTTP 000. The listener was stopped after the check. The command record retains the observed port and outcomes with local identifiers redacted. This was a diagnostic fixture, not a new llama.cpp startup or model-inference test; port 8080 in the instructions is an example.

We also ran separate IPv4 and IPv6-only fixtures in a follow-up check. The IPv6-only listener on ::1 answered HTTP 200 through the bracketed IPv6 URL, while 127.0.0.1 on the same port returned exit code 7. Both listeners were closed afterward. This demonstrates why the address family matters; it does not mean every IPv6 or wildcard listener excludes IPv4.