Deploying your application online

suggest change

A Node.js host usually sets a PORT environment variable. Listen on that value so the platform can route traffic to the process.

http in these snippets is require('http'). process.env.PORT is a string. listen accepts that string.

const http = require('http');

http.createServer(function(request, response) {
   // your server code
}).listen(process.env.PORT);

To run the same file locally when PORT is unset:

const http = require('http');

http.createServer(function(request, response) {
  // your server code
}).listen(process.env.PORT || 3000);

3000 is the local port used when PORT is not set.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents