Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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?