1

When I create a local host from Nodejs or Python it starts local host:8000 or 3000 i don't want 8000 or any number. How can I get only local host?

  • That's the port number & it's mandatory. If you mean you don't want that number to show up on the browser URL bar, then you'll have to run your server on port 80 or 443 – rdas Jul 11 '21 at 09:51
  • [node.js url without port number](https://stackoverflow.com/q/49430550/3890632) – khelwood Jul 11 '21 at 10:24
  • This is not PHP. It is required that you use a port. – Adedire Jul 11 '21 at 11:16

2 Answers2

2

This number is called PORT number. Every URL, for example localhost also have PORT 80 by default but you don't need to type it as of HTTP request connects to PORT 80 as default behavior and HTTPS connects to port 443.

To archive this, you can follow/choose one of following two ways.

  1. RUN NODEJS/PYTHON app on PORT 80 or PORT 443 (if you have SSL certificates). This way you you can access it bylocalhost without adding PORT number to URL.

  2. Install web-server like apache or nginx and use reserve proxy feature to archive it.

NOTE

  • Point 1: This is easy way and does not need knowledge required for point 2.

  • Point 2: You must have knowledge of web-servers and reserve proxy feature.

Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
1

Port Number Description: the number you see is the port number. it distinguishes between different applications in a single host (your computer for your case). for example let's say you have a website and a file server running on your computer. when you type localhost in your browser, it reaches your computer ip address but how does it know which application to request for data? webserver or file server? this is where the port number comes handy. when webserver is running on port 9000 for example and you type localhost:9000, you are telling your browser to go to your computer (localhost) and ask webserver application (port 9000) for data.

Answer to Your Question: if you type localhost without any port number, it connects to port 80 of the host by default (it's a convention or so) so if you run your application on port 80, you get what you wanted.

Extra: there is also a 443 port which is the default port for https request but i don't think you are using ssl right now.

Mahdi Sadeghi
  • 673
  • 5
  • 13