Why your friend can't open localhost:8000 (and the 4 things an AI-built app actually needs before sharing)
You asked an AI coding agent for an app and it works. The terminal prints http://localhost:8000 , the page looks right, so you paste the link to a friend. They get "This site can't be reached." Nothing is broken. localhost is not a place on the internet. It is a name for whichever computer is asking. The short answer localhost:8000 means "port 8000 on this computer". On your laptop that is your…
To share an AI-built app with a friend, it must run on a server accessible from the internet, not just on your own computer. The confusion often arises because "localhost" and "127.0.0.1" both refer to the local machine, but only "localhost" can resolve to "your laptop" and not "your friend's laptop".
On your laptop, running an app on port 8000 (localhost:8000) means the app expects traffic on that port locally. However, on your friend's laptop, nothing is listening on port 8000, so they see a "This site can't be reached" error. The app needs to run on a public server for others to access it.
There are three main ways to make an app public:
1. Tunneling services like ngrok or Cloudflare Tunnel create a public HTTPS address that forwards to your local server. This works well for quick testing but stops when your machine is off or the tunnel expires.
2. DIY hosting with a Virtual Private Server (VPS) or a platform where you manage the deployment yourself. This gives you more control over the server, but you're responsible for setup, maintenance, and costs.
3. Using a service like Tofu, where your coding agent deploys the app to a platform that handles the server for you. Tofu builds and serves the app, but it doesn't run background processes or handle updates or backups.
To make an AI-built app shareable, it needs four key components:
1. A database accessible from the hosting server, not just your local machine. This often means creating a new database instance on the server and configuring the app to use it.
2. Settings that are specific to the hosting environment, not just the local development environment. This includes API keys, email settings, and any other configurations that need to be set up on the server.
3. HTTPS security certificates, especially if the app handles sensitive data or user information. This is essential for protecting data in transit.
4. Regular updates and backups to keep the app running smoothly and ensure data is not lost.
Each method of sharing an app has its pros and cons, and the choice depends on your specific needs and technical expertise. Tunneling services are quick but temporary, DIY hosting gives you full control but requires more effort, and services like Tofu offer convenience at the cost of less control. Regardless of the method, understanding the underlying concepts of localhost, public servers, and app dependencies is crucial for successfully sharing your AI-built app with others.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to