top of page

A Hello, World! Node.js Server on Windows 10

Node.js logo

This post shows how to write, start, and stop a Node.js HTTP server that prints Hello, World!

A Hello, World! Node.js Server on Windows 10

1. Put this into a file called server.js (or click here to download one).

const http = require('http');

const hostname = '';
const port = 3000;

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

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);

2. Open the folder and right-click on Open in Terminal

Open the folder containing server.js and click Open in Terminal

3. Type node .\server.js

4. Ctrl-click on the link or open a browser and type or click here

See Hello, World! in a browser

5. Type Ctrl-c to quit


Node.js logo clipped from

The version posted at

// server.mjs
import { createServer } from 'node:http';
const server = createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello World!\n');
// starts a simple http server locally on port 3000
server.listen(3000, '', () => {
  console.log('Listening on');
// run with `node server.mjs`


bottom of page