cowhi
cowhi

Reputation: 2215

Node webserver needs the port number

this is probably a simple thing so I hope you will be kind with your answers even if the question is not so clever.

I set up a webserver and everything seems to be running fine. The only problem I have, is that I need to give the port number instead of just the IP when I want to open a website. It works fine like this http://xxx.xxx.xxx.xxx:8080 but doesn't without the 8080.

The problem is I don't even know what to look after. If you need the output of anything or more information, please let me know and I post it.

Thanks!!!

Upvotes: 0

Views: 105

Answers (2)

radar155
radar155

Reputation: 2210

You need to bind your server to port 80 for http. To do this you had to run your server with root privileges and this is really not reccommended. You can redirect your traffic from port 80 to port 8000 using iptables. Read here: Best practices when running Node.js with port 80 (Ubuntu / Linode)

Upvotes: 0

Nabil Kadimi
Nabil Kadimi

Reputation: 10384

Your server is listening on pot 8080, when there is no port on the URL, that means that the server is listening on port 80 (or 443 for HTTPS).

You should read the documentation for your server and see where the setting for the listening port resides and change the 8080 into 80.

For example, in a random script.js file using net or http modules:

server.listen(8080); // Requires that you add :8080 to the URL

server.listen(80);   // Doesn't requires that you add :80 to the URL,
                     // if you add it it will be removed by your browser.

Upvotes: 1

Related Questions