Leo T Abraham
Leo T Abraham

Reputation: 2437

How to remove port number from appear in the url for node js application?

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

Upvotes: 3

Views: 3709

Answers (2)

Munim
Munim

Reputation: 6510

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

Upvotes: 2

Jason Fetterly
Jason Fetterly

Reputation: 182

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.

Upvotes: 0

Related Questions