Before running your application on a separate server, you can make your computer a client and server by running localhost. In this video, review what localhost is and how it relates to the client-server relationship.
- [Instructor] Often clients and servers are thought to be two different computers, but who says they can't be on the same computer? One simple way to start working with clients and servers is to create a server on your computer and ping the IP address of the server on your own computer. Think of it like this. Imagine you want to test a recipe for a meal. Instead of testing the meal on a friend, you can make the meal and test it on yourself. You are both the server, the person making the meal on request, and the client, the person requesting and eating the meal. When you hit the IP address 127.0.0.1 or its equivalent in IPv6, then you are communicating with your own computer. No one else can access 127.0.0.1 on your own machine, except your machine, which is why some refer to localhost as a loop back. You can think of localhost as a domain name for your own machine, except your machine is the only one that can access it. Running localhost or a local server connection is about establishing connection to your own computer rather than another computer across the internet, and it's used for lots of different purposes. Why use localhost to run an application locally? Sometimes when you are working on an application, you don't want to put it on a remote server just yet. However, you want to simulate an internet connection while avoiding network errors. Although we will be making a simple hello world HTML application in this course, localhost can be very useful if you are creating an API, as this requires a network in order to test it. With localhost, you can test your application locally and send traffic to it while hosting it on your own computer. It's the best of both worlds for testing your application.