Connection timed out on Node.js app running under CentOS

Posted by ss1271 on Server Fault See other posts from Server Fault or by ss1271
Published on 2014-05-27T08:43:42Z Indexed on 2014/05/27 9:28 UTC
Read the original article Hit count: 236

Filed under:
|

I followed this tutorial to create a simple node.js app on my CentOS:

the node.js version is:

$ node -v 
v0.10.28

Here's my app.js:

// Include http module, 
var http = require("http"), 
// And url module, which is very helpful in parsing request parameters. 
    url = require("url"); 
// show message at console
console.log('Node.js app is running.'); 
// Create the server. 
http.createServer(function (request, response) { 
    request.resume();
    // Attach listener on end event. 
    request.on("end", function () { 
        // Parse the request for arguments and store them in _get variable. 
        // This function parses the url from request and returns object representation. 
        var _get = url.parse(request.url, true).query; 
        // Write headers to the response. 
        response.writeHead(200, { 
            'Content-Type': 'text/plain'
        }); 
        // Send data and end response. 
        response.end('Here is your data: ' + _get['data']); 
    }); 
// Listen on the 8080 port. 
}).listen(8080);

However, when I uploaded this app onto my remote server (assume the address is 123.456.78.9), I couldn't get access to it on my browser

http://123.456.78.9:8080/?data=123

The browser returned Error code: ERR_CONNECTION_TIMED_OUT.

I tried the same app.js code which runs fine on my local machine, is there anything I am missing?

I tried to ping the server and its address was reachable.

Thanks.

© Server Fault or respective owner

Related posts about centos

Related posts about node.js