What is a server?
A server is a program that waits for requests and answers them. Any computer can run one, including the laptop in front of you.
You open a food delivery app on your phone, pick your dinner and tap Place order. A moment later the screen says Order confirmed and shows an order number. Your phone did not make that number. A computer somewhere else did.
More detail
Where this page came from
The word "server" names both a machine and a program. When someone says "the server is down", the program has stopped and the machine is usually fine. Click each device to see whether it can be a server.
More detail
The machine
A physical computer. It has a processor (the chip that runs programs), memory and a network connection. Server memory covers how a server's memory is divided up.
The program
Software that runs on that machine and waits in a loop for someone to connect. Real examples are nginx and gunicorn (two widely used web server programs) and Node.js. A twenty-line program, teaching_server.py, is another example.
Back to your laptop
To reach a server, a client needs to know which machine to contact and which program on that machine to talk to. The address you type holds both. Click each colored part of the address below.
Click any colored part of the address.
More detail
Names and numbers
The host is a name because a number such as 18.141.62.7 is hard to remember and hard to change. Before anything else happens, the name has to be turned into an IP address, which is the number that identifies a machine on the network. That lookup is called DNS (the Domain Name System), and the first lookup costs a round trip of its own. Round trips and latency covers the cost.
Ports and encryption
By convention port 443 is for HTTPS and 80 is for HTTP, so browsers add them for you and hide them. A typical starter project uses 8000, which has no special meaning. https means HTTP with the conversation encrypted (scrambled so only the two ends can read it).
Paths and query strings
The developers of the server decide the path. HTTP verbs and status codes covers how to design it well. The query string is part of the address, so it appears in server logs and browser history. Never put a password in it.
An IP address picks the machine. A port picks one program on that machine. The name localhost always means your own computer. Choose who is trying to open a tool on your laptop at port 8080.
More detail
Your laptop's several addresses
A laptop has one IP address for each network connection, and each address means something different. None of them is the address of your laptop on the internet. Data on a network travels in small pieces called packets. Click each address to see how far a packet sent to it travels.
127.0.0.1 is a real address, and nothing sent to it leaves the machine. The packet goes down into the operating system's network code and turns straight back up to another program on the same computer. It still works with the wifi unplugged.
192.168.x.x is a private range. Millions of homes use the same numbers at the same time, so the number alone cannot identify anything on the wider internet. Your router assigns these addresses and keeps track of which device asked for what.
The public address belongs to your router, and every device behind the router shares it. Many private addresses sit behind that one public address, so nothing on the internet can start a conversation with your laptop.
A laptop meets the definition of a server. Serving the public internet needs six things, and your laptop has one of them. Each missing row is something a hosting company sells.
| Public hosting needs | Your laptop | A rented server |
|---|---|---|
| A program listening | yes | yes |
| An address the internet can reach | no | yes |
| An address that stays the same | no | yes |
| Ports 80 and 443 open | no | yes |
| Always awake | no | yes |
| Fast upload | no | yes |
You can now say what makes a computer a server and why a laptop is a poor one.
More detail
Why each row fails on a laptop
Your laptop's address is private, sits behind your router and shares the router's public address with every other device on that network. A home connection can be given a new address at any time. Most home internet providers block ports 80 and 443 on purpose, and these are the standard ports for HTTP and HTTPS. You close the lid, go to campus or change wifi, so the laptop is not always awake. Home plans are fast to download and slow to upload, and serving a website is all upload.
What a rented server adds
A hosting company sells a public address that does not change, an always-on machine with real upload capacity, and a network that leaves the needed ports open. Virtual machines and the cloud covers how one physical machine is divided into many rented servers, and CapEx and OpEx covers the cost.