GitHub Issue
Port collision with Ollama: mlx_lm.server fails to bind on 11434
## Summary
`npm run dev` fails to start the bundled `mlx_lm.server` when Ollama is also running, because both default to port **11434**. The MLX server hits `OSError: [Errno 48] Address already in use` and the chat never becomes ready.
## Repro
1. Have Ollama installed and running (default install puts its server on `127.0.0.1:11434`).
2. `npm run dev`
3. Electron window opens but model server crashes during startup.
## Observed error
```
OSError: [Errno 48] Address already in use
File ".../site-packages/mlx_lm/server.py", line 1984, in
File ".../socketserver.py", line 456, in __init__
File ".../socketserver.py", line 472, in server_bind
```
(Verified via `lsof -nP -iTCP:11434 -sTCP:LISTEN` showing `ollama` holding the port.)
## Root cause
`src/main/mlx.ts:6` hardcodes:
```ts
const MLX_PORT = 11434
```
11434 is also Ollama's well-known default port, so any user who runs both tools will collide. There is no fallback, port-scan, or user-facing surfacing of the bind failure — the Python traceback is only visible in the dev console.
## Suggested fix
1. **Default off Ollama's port.** Move the default to something less contested (e.g. `11534` or an ephemeral port).
2. **Auto-select a free port at startup.** Probe a small range (e.g. 11434–11444) and pick the first open one, falling back to an OS-assigned ephemeral port. Pass the chosen port to both the spawned `mlx_lm.server` and the renderer's API client.
3. **Surface bind failures** to the UI instead of...
View Raw Thread
Developer & User Discourse
rickmanelius • Apr 30, 2026
Tested PR #9 (stacked on #8) locally — works great.
- The port-collision fix lets MLX and Ollama coexist (Ollama stayed on 11434, MLX picked the next free port). `npm run dev` now starts cleanly even with Ollama already running.
- Nice side benefit: the Ollama integration auto-discovers models I'd already pulled, so I didn't have to re-download anything to try them in Gemma Chat.
Thanks for the quick turnaround.
---
### Quick security review of PR #9 (informal — sharing in case it's useful)
**Scope reviewed:** `+447/-53` across 9 files, including the new `src/main/ollama.ts`. No new npm dependencies, no new IPC channels.
**No high-risk issues found.** Specifically:
- All listeners stay bound to `127.0.0.1` — no new inbound surface.
- Pure HTTP integration with Ollama; no `spawn`/`exec` introduced.
- `model` flows through JSON bodies, never interpolated into URL paths.
- SSE parsing is defensive (`JSON.parse` wrapped in try/catch, malformed events skipped).
- Removed code (`MLX_UR...
- The port-collision fix lets MLX and Ollama coexist (Ollama stayed on 11434, MLX picked the next free port). `npm run dev` now starts cleanly even with Ollama already running.
- Nice side benefit: the Ollama integration auto-discovers models I'd already pulled, so I didn't have to re-download anything to try them in Gemma Chat.
Thanks for the quick turnaround.
---
### Quick security review of PR #9 (informal — sharing in case it's useful)
**Scope reviewed:** `+447/-53` across 9 files, including the new `src/main/ollama.ts`. No new npm dependencies, no new IPC channels.
**No high-risk issues found.** Specifically:
- All listeners stay bound to `127.0.0.1` — no new inbound surface.
- Pure HTTP integration with Ollama; no `spawn`/`exec` introduced.
- `model` flows through JSON bodies, never interpolated into URL paths.
- SSE parsing is defensive (`JSON.parse` wrapped in try/catch, malformed events skipped).
- Removed code (`MLX_UR...
SaaS Metrics
I also opened #9 as a separate draft for broader Ollama runtime support, but #8 is the small bugfix PR intended to close this issue.