Saturday, 20 May 2017

Not able to access http server running on mac from other devices in local network

I have create a http server(on my mac machine) using node js which is listening on port 8081. I am not able to access this server from other device(e.g. my mobile) using my local IP address and port. Both my laptop and my mobile are in same local network(same subnet). How can I access my server on my mobile.

Following is my code snippet.

var http = require("http");
http.createServer(function (request, response) {
   // Send the HTTP header 
   // HTTP Status: 200 : OK
   // Content Type: text/plain
   response.writeHead(200, {'Content-Type': 'text/plain'});
   
   // Send the response body as "Hello World"
   response.end('Hello World\n');
}).listen(8081);


via Vikas Goyal

No comments:

Post a Comment