How to Run AI-Generated Code Locally (Ports, Localhost, and Zero-Setup Options)
It's the first wall every vibe coder hits: the AI hands you a finished app, and you have… files. How do you actually see it? The assistant talks about "starting a dev server" and "localhost:3000," and suddenly a coding project has become a systems-administration project. Here's the whole topic in plain language, plus every practical way to get your build on screen.
Why you can't always just double-click the HTML file
Sometimes you can! A single, self-contained HTML file usually opens fine straight from your file manager. But the moment an app is split into several files or loads data, opening it directly (you'll see an address starting with file://) starts breaking things: browsers restrict what a file-opened page may load, so fetches fail, modules refuse to run, and data files won't load — often silently. The app isn't broken; it's being served wrong.
Localhost and ports, translated
Web apps are designed to be served — delivered by a program that speaks HTTP, the way a real website is. When that program runs on your own machine, its address is localhost ("this computer"), and the number after the colon — localhost:3000, localhost:8080 — is the port: which door on your machine the server answers. That's the entire concept. Nothing is uploaded anywhere; localhost is visible only to you.
A "dev server" is just such a program with developer conveniences added. The catch: something has to install it, start it, keep it running, and pick a port that isn't taken — which is exactly the setup work that stalls people who came here to build, not to configure.
Your options, from most manual to least
- A terminal one-liner. If Python is installed,
python3 -m http.serverin your project folder serves it atlocalhost:8000. Free and fine — if you're comfortable in a terminal and remember to stop and restart it. - An editor extension. Code editors have "live server" plugins that serve the open folder. Good, once you've adopted a code editor and its ecosystem.
- Asking your AI assistant to run it. Works in some environments — but it's slow (a full assistant turn per look), it spends your usage credits on a preview, and the link dies when the session does.
- A dedicated local workspace. A tool whose whole job is serving and showing your build: point it at the folder, it handles the server and the port, and the app is just… there.
Whichever route you pick, pick one
The failure mode to avoid isn't choosing the "wrong" option — it's having none, and only ever seeing your app through screenshots and assistant descriptions. Vibe coding's core loop is generate → run → look → correct. A local environment is what makes the middle two steps instant, free, and yours.