Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the whole point of "localhost", hosts and ports at all?

Tags:

localhost

I'm totally new to this web development stuff. So I see things like "localhost" all the time and ask myself: What's that?

I feel to know what a "host" actually is. Something that executes something. So my mac is the host for everything that runs on it. So "localhost" is actually just my mac? Can I have also other hosts? like "otherhost" or "betterhost"?

So when I write in my browser: http://localhost:80/mysite/index.php, this "localhost" thing tells the browser to look on my machine for that stuff rather than online?

Maybe someone can clear this up a little bit :-)

like image 895
openfrog Avatar asked Dec 22 '09 12:12

openfrog


People also ask

What is the point of localhost?

In computer networking, localhost is a hostname that refers to the current device used to access it. It is used to access the network services that are running on the host via the loopback network interface. Using the loopback interface bypasses any local network interface hardware.

What is local host and port?

Localhost is the default name used to establish a connection with a computer. The IP address is usually 127.0. 0.1. This is done by using a loopback address network. Port 80 is the common standard port for HTTP.

How many ports are in localhost?

When using a localhost, how many ports are there? Source port and destination port are 16-bit unsigned integers. So 65,535 ports, minus the reserved ones like 1–10 (I don't recall actually). But if that isn't enough ports, you can use any IPv4 address that starts with 127 as a localhost IP.

Why do we use localhost 8080?

So if in a browser, if http://localhost:8080 is entered, it simply means to server web-pages from local web-server which is listening for web-requests on 8080 port. The machine might not be connected to internet at all and still web-pages can be rendered in browser from local hard-drive.


2 Answers

In computer networking, localhost (meaning "this computer") is the standard hostname given to the address of the loopback network interface.

Localhost always translates to the loopback IP address 127.0.0.1 in IPv4.

It is also used instead of the hostname of a computer. For example, directing a web browser installed on a system running an HTTP server to http://localhost will display the home page of the local web site.

Source: Wikipedia - Localhost.


The :80 part is the TCP port. You can consider these ports as communications endpoints on a particular IP address (in the case of localhost - 127.0.0.1). The IANA is responsible for maintaining the official assignments of standard port numbers for specific services. Port 80 happens to be the standard port for HTTP.

like image 137
Daniel Vassallo Avatar answered Oct 19 '22 11:10

Daniel Vassallo


" In computer networking, a network host, Internet host, host, or Internet node is a computer connected to the Internet - or more generically - to any type of data network. A network host can host information resources as well as application software for providing network services. "-Wikipedia

Local host is a special name given to the local machine or that you are working on, ussually its IP Address is 127.0.0.1. However you can define it to be anything.

There are multiple Network services running on each host for example Apache/IIS( Http Web Server),Mail Clients, FTP clients etc. Each service has a specific port associated with it. You can think of it as this.

In every home, there is one mailbox and multiple people. The mailbox is a host. Your own home mailbox is a localhost. Each person in a home has a room. All letters for that person are sent to his room, hence the room number is a port.

like image 45
anijhaw Avatar answered Oct 19 '22 12:10

anijhaw