Article

I Turned My Laptop Into a Headless Server and Code From My Phone for Free

A story of shipping website changes from a phone while traveling, powered by Tailscale, Termius, and an AI agent. Zero paid tools.

Next.jsTailscaleOpenCodeAIDeveloper Tools

The Problem

I was traveling, and my laptop was not with me. That was fine until it wasn't. Halfway through the trip, it hit me: I wanted to ship a small change to my website. Nothing huge, just something that had been bugging me. And it was stuck, waiting for me to get back home and sit at my desk.

So I sat there, watching the trip go by, with one thought repeating in my head: when will I get access to a laptop again?

The Idea

Then it landed, quietly. I have a phone in my pocket, and that phone is on the internet. The only thing standing between me and shipping this change was a laptop. So why did the laptop even need to be in the same room as me?

I did not need the laptop physically. I needed what was inside it:

  • My project files, sitting on the disk
  • A terminal, where the real work happens
  • A way to run my website, so I can see it, not just imagine it

If I could reach those three from my phone, I could work from anywhere.

The Tools

So I started exploring, and I found two free pieces that fit together perfectly:

  • Tailscale connects my phone and my Mac through a private, secure tunnel. No public IPs, no port forwarding.
  • Termius is an SSH client that lets me open a terminal on my phone and log into my Mac.

The combo did exactly what I needed. Tailscale gives every device a private address that only my devices can reach. Termius uses that address to open a real terminal. A few minutes later, my Mac was reachable from a moving train.

Getting a Terminal on a Phone

  • Install Tailscale on your Mac and your phone, and log in with the same account.
  • Note your Mac's Tailnet IP (e.g. 100.x.y.z), its private address inside your network.
  • In Termius, create an SSH host using that IP, with SSH keys rather than a password.
  • Connect, and you are looking at your Mac's terminal, on your phone.

I was in. Next I opened my project and launched OpenCode, my AI coding agent, right inside that terminal.

The Agent in the Terminal

This was the trick that made everything reasonable. Typing a whole feature on a phone screen would have been torture. So I did not type. I ran OpenCode in the terminal and described what I wanted: fix the layout, change this copy, tweak that spacing. The agent wrote the code on my Mac while I stayed right where I was.

One pro-tip if you try this: run the agent inside tmux. My phone kept dropping Wi-Fi and hopping to 5G, and every hop killed the connection. With tmux, my agent and my dev server kept running through all of it. I just reconnected and found everything exactly where I left it.

Seeing the Change on My Phone

Making changes was only half the job. I wanted to prove they worked. Dev servers usually bind to 127.0.0.1, which means "this computer only". From a phone, that is a dead end. The fix is to bind to all interfaces so the tunnel can reach the server:

npx next dev --hostname 0.0.0.0

Next.js also blocks cross-origin requests to dev-only endpoints by default, and that kills hot reload from another device. In current Next.js (15.5+ / 16), the fix is the top-level allowedDevOrigins config:

// next.config.ts
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  // Allow your phone's Tailnet address past the dev-server origin check
  allowedDevOrigins: ["100.x.y.z:3000"],
};

export default nextConfig;

With that in place, I opened http://100.x.y.z:3000 in my phone's browser. The page updated the instant OpenCode saved a file. I was watching my website run, live, from a train.

The Two-Screen Workflow

  • Screen 1, steering. Termius with OpenCode inside. Describe a change, and the agent writes it to my Mac.
  • Screen 2, watching. The phone browser pointed at the dev server. The page updates the moment the file saves.

That is the whole loop. I ship and deploy my code from anywhere this way, without a laptop in sight.

Security and Cleanup

  • Private by default. Tailscale addresses are unreachable outside your private network.
  • Isolated. The dev server only runs when you start it, nothing more.
  • Disposable. Stop the server, switch Tailscale off, and your Mac goes back to being just your Mac.

The Point

The laptop is a means, not a requirement. The internet was already in my pocket. One afternoon, I turned my own Mac into a headless server, and now I can keep shipping regardless of where my laptop happens to be.