Run your server
Bring your server to life
⏱ Est. ~7 min
01 · Read
Your server code is written, but right now it's just a file sitting on your computer. It's not actually doing anything yet.
When you run node app.js, something magical happens: your computer transforms from a regular machine into a web server. It starts listening for requests, like a restaurant opening its doors and waiting for customers.
The address it listens on is localhost — which literally means "this computer". It's not serving the whole internet — it's serving you, right here, right now.
💡 Picture thisStarting a server is like flipping the "Open" sign on a shop. The shop was always there, but now it's ready for customers. Your computer was always there, but now it's ready to respond to web requests.
Key points
- node app.js starts your server and keeps it running
- The terminal will look "stuck" — that's normal, your server is listening
- localhost means your own computer acting as a server
02 · Real-machine exercise
Run app.js with Node to start your server. Make sure you're in the project directory (the folder with app.js and package.json).
node app.js
03 · Fill in the blank
When the server is running and the terminal looks "stuck", the server is ___ for requests.
04 · Real-machine exercise
Your server is running! Open your browser (Chrome, Safari, Firefox — any of them) and type in the address bar: http://localhost:3000 You should see the "Hello, World!" message in the browser. That text came from your server — your computer received a request from the browser and sent back a response.
http://localhost:3000
05 · Read
You just built a web server. A real one.
When you typed localhost:3000 in your browser, here's what happened behind the scenes:
1. Your browser sent an HTTP GET request to your computer's port 3000 2. Your Express server received the request 3. The app.get('/') handler matched the URL 4. Your server sent back the "Hello, World!" text 5. Your browser displayed it
This is how every website on the internet works. The only difference? Those servers run on massive machines in data centers, not your laptop. But the mechanism is exactly the same.
Key points
- Your browser is the client, your Node.js app is the server
- This is the request-response cycle that powers every website
- Back in your terminal — the server is still running, waiting for the next request
06 · Quiz
When you visit http://localhost:3000 in your browser, what happens behind the scenes?
- The browser downloads app.js and runs it locally
- The browser sends an HTTP request to your computer, your server sends back a response
- Express connects to the internet to fetch a page
- Node.js automatically opens a new browser window
Other lessons in this chapter
⚠ The full interactive experience needs JavaScript. Please enable it and reload.
※ This is an independent Traditional Chinese teaching project — not an official Anthropic product. Claude™ is a trademark of Anthropic, PBC.