localhost, though.
Cursor sends every model request through its own servers to build the prompt, so the base URL you give it has to be reachable from the internet.
This guide gives your local model a stable public HTTPS URL with ngrok, requires a token so only Cursor can call it, and connects it to Cursor.
It works on every ngrok plan, including free.
Why localhost doesn’t work
When you set Override OpenAI Base URL tohttp://localhost:11434/v1, Cursor’s servers try to call localhost on their own machines, not yours.
The request never arrives, and chat hangs or shows a connection error.
A LAN address such as 192.168.1.20 fails for the same reason.
ngrok gives your model a public URL that Cursor’s servers can reach, and forwards each request to localhost on your machine.
What you’ll need
- Cursor
- Ollama with a model pulled, such as
ollama pull qwen2.5-coder, or LM Studio with its local server started - The ngrok agent installed
- An ngrok account and your authtoken
1. Create a Traffic Policy that requires a token
Your URL is public, so anyone who finds it could use your GPU. Cursor sends its API key as a bearer token, so require one. Generate a token:policy.yaml, replacing YOUR_TOKEN with the value you generated:
Host header, because Ollama rejects requests addressed to other hostnames.
2. Put your model online
- Ollama
- LM Studio
https://your-assigned-name.ngrok-free.dev.
This is your account’s dev domain, and it stays the same every time you restart, so you only configure Cursor once.
Check it from another terminal:
qwen2.5-coder:latest; you need it in the next step.
3. Add the model to Cursor
- Open Cursor Settings > Models.
-
Under API Keys, turn on OpenAI API Key and paste
YOUR_TOKENas the key. -
Turn on Override OpenAI Base URL and enter your ngrok URL plus
/v1: -
Click Add model and enter the model ID exactly as
/v1/modelsreturned it. - Turn off other models while you test, so Cursor doesn’t fall back to a hosted one.
- Click Verify.
4. Watch the traffic
Openhttp://localhost:4040 while you chat.
The ngrok inspector shows each request Cursor sends and each response your model returns.
If chat hangs, check here first: you see whether the request arrived, whether ngrok rejected it, and what your model sent back.
What works with a local model
Cursor still sends your prompts through its servers, so a local model keeps inference on your hardware but doesn’t keep your code off the network.
Troubleshooting
Frequently asked questions
Can Cursor use a local LLM?
Can Cursor use a local LLM?
Yes, for Chat, Agent, and inline edit.
Cursor needs a public HTTPS URL for the model, because its servers make the request.
Run
ngrok http 11434 in front of Ollama and set that URL, plus /v1, as Cursor’s OpenAI base URL.Why can't Cursor reach localhost:11434?
Why can't Cursor reach localhost:11434?
Cursor routes model requests through its own servers, which can’t see your machine’s
localhost or local network.Does the ngrok URL change when I restart?
Does the ngrok URL change when I restart?
No.
Every ngrok account, including free, gets a dev domain that
ngrok http reuses on every run.Can I run the model on a different machine than Cursor?
Can I run the model on a different machine than Cursor?
Yes.
Run Ollama and ngrok on the machine with the GPU, and use its ngrok URL in Cursor on any other machine.
Is my code private if I use a local model?
Is my code private if I use a local model?
Inference runs on your hardware, but Cursor still routes prompts through its servers.
If your code can’t leave your network, a local model in Cursor doesn’t solve that by itself.
What’s next
- Secure and share your Ollama API with other apps.
- Expose a local MCP server so Cursor and other AI clients can call your tools.
- Route between local and hosted models with failover using the AI Gateway.