localhost
What is it?
Localhost is the standard hostname that refers to a machine's local loopback network interface. It typically resolves to the IPv4 address 127.0.0.1 (and ::1 for IPv6) and is used to access network services locally without leaving the host. In web and mobile development you use localhost to run and test servers, APIs and dev tools; be aware of the difference between binding to 127.0.0.1 (local-only) and 0.0.0.0 (all interfaces).
Practical example
Suppose you're developing a Node.js application and start a server on port 3000; you open http://localhost:3000 in your browser to test the app without DNS or network delay. On an Android emulator you often use 10.0.2.2 to reach the host machine's localhost, while the iOS simulator can usually access localhost directly. If you need to test from a physical device or provide external access, you must bind the server to all interfaces (0.0.0.0), use the machine's LAN IP or use tunneling tools like ngrok; you can also map a friendly local domain (e.g. myapp.local) to 127.0.0.1 via the hosts file.
Test your knowledge
Which statement about 'localhost' is correct?