Fix "Unable to Find Package" NuGet Error in Visual Studio C#
Everything connected to the internet can be found using a socket address. Socket Addresses
are a combination of IP addresses
(or simply hostname) and port numbers
. Socket Addresses are used to identify both machine and the service within the machine. If we consider localhost:8080 then here localhost is the hostname which is bound to the IP address ie. 127.0.0.1 by default and 8080 is the port. Here, localhost means this computer ie. the computer which you are using right now.
Ip address is just like a house address which finds the right house. Similarly, Ip finds a particular system in a network.
Port is the person's number. Person number which finds an actual person on that house. Similarly, Post is used to identify the process that needs to consume the packet.
In localhost:8080, localhost is a DNS hostname that is pointing to the localhost IP address ie. 127.0.0.1. If you type ping localhost in terminal or command prompt, you will find that your machine automatically points localhost to IP addresses such as :1 or 127.0.0.1. Actually, 127.0.0.1 is the IPV4 address and::1 is the IPV4 address of localhost.So typing localhost:8080 or 127:0:0:1::8080 are same things. Here 127:0:0:1 is a private Ip address that is not recognizable by another computer in the network. It is recognized by this machine only.
Generally while building the application locally by the web developer, they develop the web application and the default socket will be localhost:8080. This is the default port that the webserver XAMP, WAMP, and LAMP server uses for developing and testing the application.8080 is just a random port someone sets in different web servers for testing and development and you can change it if you want.
But note that no two applications or processes can use the same port. ie. two applications running cannot run on port 8080 at the same time. If one process is using 8080 then if another application tries to access 8080 then it will give you a message like "port is already in used" please use another port.
If you are running a .net application or PHP application and when you are debugging that application it will have localhost:8080 upon running in the browser URL by default. The web server will not search the information on the internet but will search pages in a local hard drive it will search for the webpage by local webserver at port 8080 from the local hard drive
If you are using a windows machine, then the IIS server is enabled then just typing localhost will redirect you to C:/inetpub/wwwroot/iisstart.htm files. Here the port by default is 80. Considering the C drive is your OS drive.
Similarly, if you use the XAMP server then typing localhost will just find the content like index.html or index.php present in htdocs folder.
URL Syntax : {scheme}://{hostname}:{port}{path} then for localhost:8080 , {scheme} is "http" , {hostname} is "localhost", {port} is 8080 and {path} is "/"
It is to be noted that there is a total of 65,535 ports for communication between the devices where 0-1023 are well-known reserved ports you cannot assign IP to this. Port 1024 to 49151 are user ports and users can assign applications to them. And port above 49151 is a private port. So, port 8080 is the user-registered port. In our case by default XAMP or WAMP server assign for the application.
If you have a web server already running on default port 80 and you like to host another web server on the HTTP service then the web server will automatically host you to port 8080 which is a best practice followed by most web servers and if that port is also in use then may assign any user port like 8081,8082 etc
You can change it, the only thing you have to keep in mind is that you cannot assign an already used port otherwise it will give an error as we have mentioned earlier.
8080 must be explicitly specified for HTTP as 80 will be assumed by most browsers. But some web server like Angular, and Rails server uses 8000, 4200 as the default port
Ans: When you type localhost:8080, this will make your web browser ask your operating system to do a DNS lookup and resolve the hostname as localhost.
The operating system looks at the files for DNS lookup.
In the windows system, the DNS mapping is located inside the host's file located inside the %systemroot%\System32\Drivers\Etc path and the host's file looks like this:
In Unix systems like Linux, the DNS mapping is stored inside /etc/hosts file, and looks like this:
So when you hit localhost:8080 the browser then the webserver finally gets the result from the 127.0.0.0:8080 location and displays the result in the browser.
FAQ:
Ans: Yes both localhost:8080 and 127.0.0.1:8080 point to the same IP address on TCP port 8080.
Yes.They are equivalent.So, typing localhost:80/test is equal to 127.0.0.1:80/test
Sometimes port 80 is already in use; in this case, try using the 8080 port in Xamp. Let's look at how to change it.
Conclusion:
When you run a web server on your local computer, you will have to connect a web application with the web server and port 80 is already in use, so you will need to use a new port. So, most of the web server usage available port 8080 to connect the application which is currently running. If port 8080 is already in use by some other process then the web server may assign 8081 for the application.