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

Finley Williamson
Finley Williamson
11,375 Points

Workspace Unavailable?

Chalkers tells us to preview the workspace on port 3000. I do as instructed, only to be brought to a 'Workspace Unavailable' page.

I feel the rest of this tutorial will be difficult (if possible) without the ability to preview my work.

Here is a snapshot of my workspace: https://w.trhou.se/1md8oj4xt9

Please help me I feel this tutorial covers an important skill.

Thanks, Finley

lauralouise
lauralouise
14,851 Points

hi! I think you have a problem in your code -- you've changed "req" and "res" to "request" and "response", but you have replaced "res" with "request" in your code. Below is my code, which works:

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

1 Answer

sergio alvarez
sergio alvarez
15,205 Points

I had the same problem, it was an error on my code, you can tell if you have an error by checking the console. if the server has disconnected you will have problem, check the response, for me it was a spelling error, example:

node app.js
Server running at http//<workspace url>
/home/treehouse/workspace/app.js:5
response.wite("this is before the end\n");
^

TypeError: response.wite is not a function
at Server.<anonymous> (/home/treehouse/workspace/app.js:5:12)
at emitTwo (events.js:126:13)
at Server.emit (events.js:214:7)
at parserOnIncoming (_http_server.js:660:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)