"localhost:8080" works fine but "localhost" doesn't

"localhost:8080" works fine but is it mandatory to give the port number always, because it doesn't work when I just type "localhost"

4

2 Answers

The IANA has assigned 80 as the HTTP well-known port number.

So browsers use this port by default.

If something is listening on a different port, you have to specify the port.

If you want your localhost-listening webserver to accept requests on port 80, you need to configure it to do that.

3

if you want localhost to behave like localhost:8080 you have to configure apache to open the both ports. here is how:

  1. Open apache configuration file. (httpd.conf you knew that.)
  2. Search for the word Listen and you will see something like this:
Listen 127.0.0.1:8080
  1. Add this line after it and save it. then restart apache.
Listen 127.0.0.1:80

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like