2

I am new to web servers and node.js and I need some help.

I have no idea what to put in the .listen();

I think since I want it to connect to the internet the server needs to listen to port 80 but but I don't know what to put as the second value.

.listen(80, "What do I add here?");

Also i have a free domain name (www.example.co.cc) that is pointing to a dynamic dns (DnsExit) since I dynamic ip. I installed to program needed to update my ip address.

Is there anything I am missing?

1 Answer 1

1

Have you seen the example on the homepage of the Node.js project?

It clearly demonstrated .listen( 1337, "127.0.0.1" ); and then the next line reads Server running at http://127.0.0.1:1337/ - so the second argument is the IP you want to listen on. If you then take a look at the documentation you will see that this second argument is actually optional, if you omit it, Node.js will accept incoming connections directed at any IPv4 address.

Sign up to request clarification or add additional context in comments.

5 Comments

yes i have seen but as i have said i am new and have no idea what i am doing but anyway i left the second argument out and connect to the server through localhost:80 but cant connect to the server through my domain name. do u know what the problem is? and can u give me any references on this subject?
How are you testing the connection via your domain? Because, usually you cannot connect to your own IP address (if you are behind NAT, which most people are). So if your external IP is 1.2.3.4, and your domain is pointing to 1.2.3.4, going to your own domain won't work. Try your domain on this: web-sniffer.net
I have already forwarded port 80 and on web-sniffer.net it gets the right ip address and port 80 but it fails to connect. here is what web-sniffer said: Connect to (My ip) on port 80 ... failed Error 110: Connection timed out Error while fetching URL
If it's working from localhost, then my guesses would be either it's only listening to local (you could try second argument 0.0.0.0, but according to the documentation it already uses something similar internally if you omit it.) or there is something wrong with your port forwarding / firewall settings.
changing the argument didnt work but thanks for all ur help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.