What an HTTP Server actually does
A server is a program that never stops listening. Files and CLIs were a one-shot conversation. A server stays running, waits for requests, and answers each one. That is the entire shift from batch processing to serving.
Your computer can run many servers at once. Ports are how the operating system tells them apart. When your code says listen on port 3000, you are claiming that address on your machine. If something else already has it, you get an error. Common ports worth knowing: 80 for HTTP, 443 for HTTPS, 3000 for Node dev, 5432 for Postgres, 6379 for Redis.
A request through a tiny server
Browser sends a request to a port. The server reads the method and the path, decides what to do, and writes a response back.
Every HTTP server, no matter how fancy, is doing the same three things. Bind to a port. Read the incoming request. Send a response. The frameworks differ in how nicely they let you express the middle step, but the core loop is identical.
Quiz: Quiz
Loading practice…