localhost:11434.
That address only works on that machine.
Apps in the cloud, a laptop on another network, and tools like Cursor can’t reach it.
This guide shows you how to give Ollama a stable public HTTPS URL with ngrok and require a token, so only you and the apps you choose can call your models.
It works on every ngrok plan, including free.
What you’ll need
- Ollama installed, with at least one model pulled, such as
ollama pull llama3.2 - The ngrok agent installed
- An ngrok account and your authtoken
1. Check that Ollama responds
Make sure Ollama is running and answers on its default port:2. Create a Traffic Policy that requires a token
Generate a long random token:ollama.yaml, replacing YOUR_TOKEN with the value you generated:
Authorization: Bearer YOUR_TOKEN.
ngrok enforces it in its cloud, so rejected requests never reach your machine.
The second rule rewrites the Host header to localhost, because Ollama rejects requests addressed to other hostnames.
A bearer token is what OpenAI-compatible clients send in their API key field, so the same token works in curl, the OpenAI SDKs, Cursor, and Open WebUI.
3. Put Ollama online
https://your-assigned-name.ngrok-free.dev.
This is your account’s dev domain.
It stays the same every time you restart ngrok http, so you configure each client once.
4. Try it out
From any machine, send a prompt to your model, replacingYOUR_TOKEN and the model name with your own:
Authorization header and you get 401 Unauthorized.
Open http://localhost:4040 on the Ollama machine to watch each request and response in the ngrok inspector.
5. Connect your apps
Any app that speaks the OpenAI API can use your Ollama models. Set its base URL to your ngrok URL plus/v1, and its API key to your token.
- OpenAI SDK (Python)
- Cursor
- Open WebUI
Use a custom domain
On a paid plan, you can use your own domain, such asllm.example.com, instead of your dev domain.
Reserve the domain, then pass it with --url:
Frequently asked questions
How do I access Ollama remotely?
How do I access Ollama remotely?
Run
ngrok http 11434 with a Traffic Policy that requires a token, then call your ngrok URL from anywhere with Authorization: Bearer YOUR_TOKEN.
Ollama keeps listening on localhost, so nothing on your machine is exposed beyond what ngrok lets through.Why not set OLLAMA_HOST=0.0.0.0?
Why not set OLLAMA_HOST=0.0.0.0?
That makes Ollama listen on your local network, not the internet.
It also has no authentication or HTTPS, so anyone on the same network can use your models.
ngrok gives you a public HTTPS URL and enforces the token before traffic reaches your machine.
Does the URL change when I restart?
Does the URL change when I restart?
No.
Every ngrok account, including free, gets a dev domain that
ngrok http reuses on every run.Why do I get a 403 from Ollama?
Why do I get a 403 from Ollama?
Ollama rejects requests whose
Host header isn’t localhost.
Keep the add-headers rule in your policy, or start ngrok with --host-header=localhost:11434 instead.Does this work with LM Studio or vLLM?
Does this work with LM Studio or vLLM?
Yes.
Point
ngrok http at their port instead, such as 1234 for LM Studio or 8000 for vLLM, and keep the token rule.
To route across several model servers with failover, use the AI Gateway.What’s next
- Use your Ollama models in Cursor.
- Expose a local MCP server so AI apps can call your tools.
- Replace the token with IP restrictions or OAuth, or block unwanted requests from bots.
- Route between Ollama and hosted providers with the AI Gateway.