Hosting — Where Your Code Lives
The bookshop API runs perfectly at http://localhost:8000. You send the link to a friend, and it fails for them. Your laptop is not always on, it has no public address, and localhost always means "this machine". To be reachable by the world, code needs a host.
The rule
Hosting is renting a computer that is always on, reachable and looked after.
Any hosted backend needs the same few things: a machine that stays running, a public address with a DNS name pointing at it, a process listening on a port, a TLS certificate for HTTPS, a way to restart after crashes, and logs you can read.
The options differ in who looks after what:
| Option | You provide | The provider looks after |
|---|---|---|
| Dedicated server | everything above the hardware | power, network, hardware |
| Virtual private server (VPS) | OS updates, runtime, your app | the physical machine, split into virtual ones |
| Platform as a service (PaaS) | your code and settings | OS, runtime, restarts, often certificates |
| Serverless functions | individual functions | everything else, starting them per request |
| Static hosting / CDN | plain files | serving them from locations near users |
Shared hosting, where many small sites live on one managed machine, is the cheapest older option, mostly for simple PHP sites.
A detail that trips up beginners: a server program must listen on the right interface. Listening on 127.0.0.1 accepts connections only from the same machine; listening on 0.0.0.0 accepts them from outside too.
uvicorn app:app --host 0.0.0.0 --port 8000The shortcut
The more the platform manages, the less you control and the less you maintain. Ask one question: "Do I need to control the operating system?" If no, move right in the table toward a platform. If yes, move left toward a VPS.
Push the code
You connect your Git repository. The platform builds your app, installing its dependencies.
Keep the frontend's plain files separate in your head: HTML, CSS and images need no running process, so static hosting behind a CDN is simpler and cheaper than any server.
Drills
Answer fast — trust the rule.
You need to install a custom system package and tune the operating system. Which option fits?
Your API works at http://localhost:8000. Can a friend on another network open that address?
A site is only HTML, CSS and images, with no server code. What is the simplest host?
On a platform service, who normally applies operating-system security patches?
Your hosted API only answers when you connect from the server itself. What is the likely cause?
Remember
- Hosting is renting a computer that is always on, reachable and looked after.
- More management means less control and less maintenance: choose by whether you need the OS.
localhostand127.0.0.1never reach the outside world.
