3

I am new to node js. In my application url, port number has to be specified like localhost:3000/a. How can I remove that port number from appearing in the URL. I tried out by giving the port number as 80. But it didn't worked for me.

Even when I set the port as 8080, I have to specify the port number 8080, in order to work. If it is not specified, it raise 404, just like the just like the simple server behave.

Please help me with a solution. Thanks in advance

Leo T Abraham
  • 2,407
  • 4
  • 28
  • 54
  • 1
    What OS are you running on? Windows will let you run on port 80 but Linux requires elevated privileges to do so. – dc5 Aug 12 '13 at 04:53
  • I am using windows 7. It is working only when the port is specified, 8080. – Leo T Abraham Aug 12 '13 at 04:54
  • Does this answer your question? [Node.js - How can I remove the port from the url?](https://stackoverflow.com/questions/9526500/node-js-how-can-i-remove-the-port-from-the-url) – wilo087 May 14 '20 at 12:57

2 Answers2

2

If you want to use port 80, you should run your application with root/administrator privileges, and make sure no other server is running on that port. In practice, most people deploy a reverse proxy to handle static content and route the rest of the requests to the node.js application. nginx is usually used for this. You will find plenty of resources explaining how to do this, but a quick google search gave me this

Munim
  • 6,310
  • 2
  • 35
  • 44
0

Yes, using port 80 should work. You have to make sure the node app is configured to list on port 80 as well... If you've tried this, you should update your question with more detail because you don't specify what happened when it didn't work for you.

Jason Fetterly
  • 182
  • 1
  • 12
  • I have made some edits to the question. Hope it will give more details. Please let me know if any clarifications are required. – Leo T Abraham Aug 12 '13 at 04:39