Running AI models locally with Ollama gives you complete control over your data and inference. But what if you need to access these models remotely? Whether you’re collaborating with team members, testing applications from different locations, or integrating AI into web apps, forwarding Ollama’s default port 11434
is essential to enable online access.
This guide walks you through port forwarding Ollama securely, letting you expose your local AI models online without compromising privacy or performance.
Why Forward Ollama Port 11434?
By default, Ollama binds to port 11434
on localhost, which means it’s accessible only on your own machine. This setup is secure but limits remote usability. Forwarding this port lets you:
- Access models from anywhere with an internet connection
- Integrate AI into web applications on other servers
- Share models with team members without complex VPN setups
- Test applications remotely before production
- Enable mobile apps to use your local AI models
Compared to cloud deployment, forwarding the port offers zero cloud costs, complete data privacy, full model control, and instant deployment without complex configurations.
Prerequisites
Before forwarding, make sure Ollama is installed and ready:
- Install Ollama: Follow the instructions for your operating system.
ollama --version
Confirm installation.
- Download a Model: Test with a small model first:
ollama run qwen:0.5b
For larger or multimodal models:
ollama run llama3:8b
ollama run llava:13b
Step-by-Step Guide to Forward Port 11434
Step 1: Start Ollama Server
Ensure Ollama is running on the default port:
ollama serve
Keep this terminal open; it needs to handle API requests.
Step 2: Create a Secure Tunnel with Pinggy
Use Pinggy to forward port 11434
securely:
ssh -p 443 -R0:localhost:11434 -t qr@free.pinggy.io "u:Host:localhost:11434"
Command Breakdown:
-
-p 443
: Uses HTTPS port for better firewall compatibility -
-R0:localhost:11434
: Maps your local port11434
to a remote port -
qr@free.pinggy.io
: Pinggy’s tunneling server -
u:Host:localhost:11434
: Connects the tunnel to your Ollama server
Step 3: Get Your Public URL
After running the command, Pinggy provides a public URL like:
https://abc123.pinggy.link
This URL forwards all requests to your local Ollama server.
Testing Remote Access
Verify your forwarded port:
Browser Test: Open the Pinggy URL in a browser; you should see Ollama responding.
Command Line Test:
curl https://abc123.pinggy.link/api/version
curl https://abc123.pinggy.link/api/tags
Model Inference Test:
curl -X POST https://abc123.pinggy.link/api/generate \
-H "Content-Type: application/json" \
-d '{"model": "qwen:0.5b", "prompt": "Hello, world!", "stream": false}'
Integrating with Applications
To use the forwarded Ollama API in your apps:
- Clone the test repository:
RunOllamaApi
- Install dependencies:
npm install
- Update the API URL in your code with your Pinggy URL
- Run the test:
node main.js
This gives a full example of integrating and testing your forwarded API with JavaScript applications.
Adding Open WebUI
For a ChatGPT-like interface, you can set up Open WebUI:
docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main
Forward the WebUI port:
ssh -p 443 -R0:localhost:3000 free.pinggy.io
Access the interface using the generated URL and configure it to use your forwarded Ollama API.
Why Add Open WebUI?
- User-friendly ChatGPT-like interface
- Upload documents for RAG-based queries
- Easily manage multiple models
- Share interface with team members
Conclusion
Forwarding Ollama’s port 11434
opens up remote access to your local AI models while maintaining data privacy. Using Pinggy’s secure tunneling, you get cloud-like accessibility without cloud costs. Coupled with Open WebUI, you can interact with your models in a user-friendly interface, making development, testing, and collaboration much easier.
Always implement proper security when exposing local services online, especially for production use.
Top comments (0)