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 8000