ThisCalculator

Everyday

Remote Access to Local Coding Model: How-To

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Remote Access to Local Coding Model: How-To

This article explains how to securely connect to a local coding model (like one running on your home PC via Ollama, LM Studio, or vLLM) from another location, such as your workplace or a coffee shop. You’ll learn the key methods—SSH tunneling, VPN, and cloud relay—along with their trade-offs, setup steps, and security considerations. By the end, you’ll know which approach fits your needs and how to implement it safely.

Why You’d Want Remote Access

Local coding models offer privacy, offline availability, and full control over your data. However, their convenience evaporates when you’re away from your machine. Remote access lets you use your home server’s GPU power and your fine-tuned model from any device with an internet connection. It’s especially useful if you’re traveling, working from a café, or need to access a model that’s too large for your laptop.

Methods to Connect

There are three primary ways to reach your local model remotely:

  • SSH Tunneling – Encrypts traffic and forwards a port from your local machine to a remote server. Ideal for occasional, single-user access.
  • VPN – Creates a secure network tunnel that makes your remote device appear as if it’s on your home network. Good for multiple users or persistent access.
  • Cloud Relay / Tunneling Services – Uses a third-party service to expose your local port via a public URL, often with authentication. Simplest for one-off sharing.

Prerequisites

Before you start, ensure your local model is running and listening on a network interface. Most tools bind to 127.0.0.1 by default; you’ll need to change that to 0.0.0.0 to allow external connections, but only if you’re using a VPN or SSH tunnel that already restricts access. If you’re using a cloud relay, the service handles the public exposure, so you can keep the model bound to localhost.

You also need a stable internet connection at home, a way to access your home network (like a dynamic DNS service if your IP changes), and a client application that can talk to the model’s API (usually HTTP).

Step-by-Step: SSH Tunneling

SSH tunneling is the most straightforward method if you have a computer at home that you can SSH into from outside. Here’s how:

  1. Ensure SSH is enabled on your home machine and that you can connect to it from your remote device (you may need to set up port forwarding on your router for port 22).
  2. Start your local model, noting the port it uses (e.g., Ollama uses 11434, LM Studio uses 1234).
  3. On your remote device, run: ssh -L 8080:localhost:11434 user@your-home-ip. This forwards your local port 8080 to the model’s port on the home machine.
  4. Now, on your remote device, you can send requests to http://localhost:8080 and they’ll be securely tunneled to your model.

This method encrypts all traffic between your devices, protecting your prompts and responses from eavesdroppers.

Step-by-Step: VPN Setup

A VPN (like WireGuard or OpenVPN) is more robust if you need to access multiple services or have several users. The setup is more involved:

  1. Install VPN server software on your home machine (or a dedicated device like a Raspberry Pi).
  2. Configure the VPN with a static IP range, and assign a client config to your remote device.
  3. Forward the VPN port (e.g., 51820 for WireGuard) on your router.
  4. Once connected, your remote device gets a virtual IP on your home network, so you can access the model at its local IP (e.g., http://192.168.1.50:11434).

VPNs are ideal if you plan to use the model regularly and want to avoid reconfiguring tunnels each time.

Step-by-Step: Cloud Relay

Cloud relay services (like ngrok, Cloudflare Tunnel, or Tailscale Funnel) provide a public URL that forwards to your local port. They’re the quickest to set up but introduce a third party and potential latency.

  1. Install the relay client on your home machine.
  2. Run a command like ngrok http 11434 to get a temporary public URL.
  3. Use that URL from anywhere, but be aware it’s exposed to the internet—always add authentication if the service supports it.
  4. For persistent access, consider a service that offers a static subdomain and built-in authentication.

This method is great for sharing a model with a colleague for a short time, but not recommended for long-term personal use without security hardening.

Security and Common Pitfalls

Exposing a model to the internet without protection is dangerous—anyone can send prompts, potentially incurring costs or accessing sensitive data. Always use encryption (SSH or VPN) and add API keys or authentication layers. Common mistakes include:

  • Leaving the model bound to 0.0.0.0 without a firewall, allowing anyone to connect.
  • Using default ports that are easily scanned.
  • Forgetting to update the model software, leaving known vulnerabilities.
  • Not using a dynamic DNS service if your home IP changes, causing you to lose access.

If you’re using a cloud relay, ensure the service has end-to-end encryption and that you trust the provider. For maximum security, combine a VPN with a local firewall rule that only allows traffic from the VPN subnet.

Frequently Asked Questions

Can I use a free cloud relay service for production?

Free tiers often have bandwidth limits and temporary URLs, making them unsuitable for continuous production use. They’re fine for testing or occasional access, but for reliability, consider a paid plan or a self-hosted VPN.

What if my home internet has a dynamic IP?

Use a dynamic DNS service (like DuckDNS or No-IP) that assigns a hostname to your changing IP. Then you can connect via that hostname instead of an IP address.

Is SSH tunneling faster than a VPN?

SSH tunneling is typically lighter and faster for a single port, but a VPN can be more efficient for multiple services. The difference is usually negligible for model inference, which is more limited by GPU speed than network latency.

Can I access my model from a mobile device?

Yes, as long as you have an SSH client or VPN app on your phone. You can then use a mobile browser or API client to send requests to the tunneled port.

What if my model only runs on localhost?

Most tools allow you to change the bind address. For example, in Ollama, set OLLAMA_HOST=0.0.0.0 before starting. But if you’re using SSH tunneling, you can keep it on localhost and still access it remotely.

Do I need a static IP for my home router?

Not strictly, but port forwarding rules may change if your router’s IP changes. A static IP from your ISP eliminates this, but dynamic DNS is a cheaper workaround.

Related

Formula used

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.