I installed node.js on a hosted Apache server. The simple server I placed on the server runs fine, but when I go to the website I cannot see the website.
I initially tested this on my local machine and it works fine, but I need this on a production website. How can I do this.
My Node.js code
[code]
// Load the net module to create a tcp server.
var net = require('net');
// Setup a tcp server
var server = net.createServer(function (socket) {
// Every time someone connects, tell them hello and then close the connection.
socket.addListener("connect", function () {
sys.puts("Connection from " + socket.remoteAddress);
socket.end("Hello World\n");
});
});
// Fire up the server bound to port 7000 on localhost
server.listen(1337, "localhost");
[/code]
// Put a friendly message on the terminal console.log("TCP server listening on port 1337 at localhost.");
Then I run node test.js Response : TCP server listening on port 1337 at localhost.
Then I go to www.mywebsite.com:1337
Oops! Google Chrome could not connect to www.mywebsite.com:1337
So I tried using the actual IP server.listen(1337, "xx.xx.xx.xx");
And the URL server.listen(1337, "http://mywebsite.com"); // this actually broke the server immediatly
So how can I do this?
iptables -t filter -L
? – Chris Jan 1 '13 at 17:31INADDR_ANY
rather than just127.0.0.1
:server.listen(1337);
. Or try:server.listen(1337, "mywebsite.com");
(difference being server name only; nohttp://
protocol). Also ensure that your host allows connections on port1337
. Depending on your hosting plan, the list of supported port #s may be rather short. If you have "private" or "dedicated" hosting, you may be able to alter the firewall yourself to allow1337
. – Jonathan Lonowski Jan 1 '13 at 19:23