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 trial

JavaScript Build a Simple Dynamic Site with Node.js Creating a Simple Server in Node.js Creating a Simple Server

The server running on the console but not in the preview

Hi, my node server is running through the terminal. but when I try to preview I get an error.

const http = require('http');

const hostname = ''; const port = 3000;

const server = http.createServer((request, response) => { response.statusCode = 200; response.setHeader('Content-Type', 'text/plain'); response.end('Hello World!\n'); });

server.listen(port, () => { console.log(Server running at http://<workspace-url>/); });

I've also tried to copy-paste the exact code from node docs. Thank you

What error did you receive?

The problem has been fixed. Thanks.

1 Answer

I am having the same issues. How did you fix it?