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

2 questions

Doesn't the status change depending on whether the request was successful? Why explicitly set it to 200?

Does it make a difference whether I use port 3000, 1337, 80, 8080, 4567, etc?

1 Answer

Steven Parker
Steven Parker
229,732 Points

The status is set to 200 to indicate that the message you are sending is the result of a successfully handled request. If you were sending back an error message, you'd use a different response code.

The port number chosen must be one not already in use by another service on the same machine. Plus, it's a good practice not to use one commonly associated with a specific service unless it's what you are providing. A list of commonly used ports can be seen on this Wikipedia page.