Skip to the workspace
Pebellslearn by building
How the Web Works  ›  Lesson

Hosting — Where Your Code Lives

What is hosting? 12 minHosting means running your code on a machine that is always on and publicly reachable, and the options trade control against how much the provider manages for you.

backend / Hosting — Where Your Code Lives

Explore each scene at your own pace.

01 · The rule

The rule

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
Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.