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


Henrik Christensen
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

node.js server


When publish your node.js project would you still use the createServer() or is this for developing only?

would this be put online?

const http = require('http');

const hostname = '';
const port = 3000;

const server = http.createServer((req, res) => {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
Phillip Kerman
Phillip Kerman
Courses Plus Student 285 Points

Yes--it's not as if "createServer" creates a permanent server though may be intuitive. If this file is named server.js you can first do: node server.js Then launch your browser to (and see Hello World).

As soon as you kill the process (like "ctrl+c" or close the command line), you won't see anything when your browser goes to

Is that what you mean?