Module 5: IP Addresses and Ports
localhost
๐ The everyday picture
Leaving yourself a note on your own fridge. It never leaves the house; you're both sender and receiver.
๐What it really is
- localhost is a special name meaning "this computer". Its address is
127.0.0.1(IPv4) or::1(IPv6). - Data sent to localhost never leaves your machine. It's perfect for testing.
-
When you build a website or app on your computer (Level 2 onwards), you'll open it at an address like
http://localhost:3000. Only you can see it, until you deploy it to a real server. -
If an app works on localhost but not online, the problem is in the deployment, not usually in the app idea.
๐ฑ๏ธTry it
In your terminal, type ping localhost (on Mac, press Ctrl + C to stop). You'll see replies in well under a
millisecond: your computer talking to itself.
โ Quick check
You send a friend the link http://localhost:3000 to see your new app. What will they see?
Show the answer
Nothing of yours. On their computer, localhost means their own computer, where your app isn't running.
Why do developers test on localhost first?
Show the answer
It's fast, private and safe. Mistakes don't affect real users.
