node.js - How to make my computer as a public server in NodeJS or any other way? -


i want make computer public server. tried following code nodejs. instead of giving hostname 127.0.0.1 maked real ip address. didn't works. reason? possible create public server in way? or there other alternative ways?

const http = require('http');  const hostname = '175.157.210.25'; const port = 3000;  const server = http.createserver((req, res) => {     res.statuscode = 200; res.setheader('content-type', 'text/plain'); res.end('hello world\n'); });  server.listen(port, hostname, () => {     console.log(`server2 running @ http://${hostname}:${port}/`); }); 

output

c:\users\nuwanst\documents\nodejs\test2>node app.js events.js:160       throw er; // unhandled 'error' event       ^  error: listen eaddrnotavail 175.157.210.25:3000     @ object.exports._errnoexception (util.js:1018:11)     @ exports._exceptionwithhostport (util.js:1041:20)     @ server._listen2 (net.js:1245:19)     @ listen (net.js:1294:10)     @ net.js:1404:9     @ _combinedtickcallback (internal/process/next_tick.js:83:11)     @ process._tickcallback (internal/process/next_tick.js:104:9)     @ module.runmain (module.js:606:11)     @ run (bootstrap_node.js:389:7)     @ startup (bootstrap_node.js:149:9)  c:\users\nuwanst\documents\nodejs\test2>node app.js events.js:160       throw er; // unhandled 'error' event       ^  error: listen eaddrnotavail 175.157.210.25:3000     @ object.exports._errnoexception (util.js:1018:11)     @ exports._exceptionwithhostport (util.js:1041:20)     @ server._listen2 (net.js:1245:19)     @ listen (net.js:1294:10)     @ net.js:1404:9     @ _combinedtickcallback (internal/process/next_tick.js:83:11)     @ process._tickcallback (internal/process/next_tick.js:104:9)     @ module.runmain (module.js:606:11)     @ run (bootstrap_node.js:389:7)     @ startup (bootstrap_node.js:149:9) 


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -