Can not run my nodejs project Helloworld on Centos 7

Posted April 2, 2019 3.8k views

I installed NodeJS by following link:
But when I test my nodejs project HelloWorld, the system show errors:
File hello.js:
var http = require(‘http’);
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type’: 'text/plain’});
res.end('Hello World\n’);
console.log('Server running at’);
System show error:
Server running at
throw er; // Unhandled 'error’ event
Error: getaddrinfo ENOTFOUND
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
Emitted 'error’ event at:
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1448:12)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:17)
How can I fix this?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


Thanks for posting the question here so that others can learn from it as well. I believe the problem is with this line:


I believe it should instead read:


Just removing the protocol and putting the address only there.