Report this

What is the reason for this report?

Can not run my nodejs project Helloworld on Centos 7

Posted on April 2, 2019

I installed NodeJS by following link: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-centos-7 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’); }).listen(8080,‘http://10.132.36.167’); console.log(‘Server running at http://10.132.36.167’); System show error: Server running at http://10.132.36.167 events.js:174 throw er; // Unhandled ‘error’ event ^ Error: getaddrinfo ENOTFOUND http://10.132.36.167 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? Thanks



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

Greetings!

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

}).listen(8080,'http://10.132.36.167');

I believe it should instead read:

}).listen(8080,'10.132.36.167');

Just removing the protocol and putting the address only there.

Jarland

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.