Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialClint Oka
5,768 PointsCan't get my port to show Hello World...
Here's my code
const http = require('http');
//const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
});
server.listen(() => {
console.log(`Server running at http://<workspace>/`);
});
this is the error I get
This site canβt be reachedlocalhost refused to connect. Try:
Checking the connection Checking the proxy and the firewall ERR_CONNECTION_REFUSED
1 Answer
Clint Oka
5,768 PointsProblem solved. I didn't run the app.js in the terminal. Once I did node app.js in the terminal and got the server running. I can see Hello World.
Marni Ali
4,642 PointsMarni Ali
4,642 PointsHi Clint, I did my code like yours but I still can't seem to see the Hello World. How did you solve yours? I dont quite understand your solution from your comment above. PS: I am using the workspace btw.