http-server
Serve files over HTTP (simple webserver)
TLDR
Start an HTTP server listening on the default port to serve the current directory
Start an HTTP server on a specific port to serve a specific directory
Start an HTTP server using basic authentication
Start an HTTP server with directory listings disabled
Start an HTTPS server on the default port using the specified certificate
Start an HTTP server and include the client's IP address in the output logging
Start an HTTP server with CORS enabled by including the Access-Control-Allow-Origin: * header in all responses
Start an HTTP server with logging disabled
SYNOPSIS
http-server [options] [<path>]
PARAMETERS
-p, --port <port>
Port to listen on (default: 8080)
-a, --address <address>
Address to bind to (default: all interfaces)
-d, --directory-listing
Enable/disable directory listings (default: enabled)
--cors
Enable CORS headers (Access-Control-Allow-Origin: *)
--corslist <origins>
Comma-separated list of allowed origins
-o, --open
Open browser window on startup
-s, --silent
Suppress log messages
--gzip
Enable GZIP compression
--brotli
Enable Brotli compression
-c, --cache <seconds>
Cache time in seconds (default: 3600)
-w, --watch
Watch for file changes and reload
--https, -S
Enable HTTPS
--cert <path>
Path to SSL certificate
--key <path>
Path to SSL private key
--proxy <host:port>
Proxy requests to another host
--spa
Serve single-page apps (no .html except index)
--basic-auth <user:pass>
HTTP basic authentication
--no-dotfiles
Don't show dotfiles in listings
-h, --help
Display help
-v, --version
Show version
DESCRIPTION
http-server is a simple, zero-configuration command-line tool for serving static files via HTTP. Built with Node.js, it is installed via npm and instantly turns any directory into a web server accessible at http://localhost:8080 by default.
Key features include automatic directory listings, GZIP/Brotli compression, CORS support, file watching for live reloads, HTTPS with custom certificates, proxying, HTTP basic auth, and SPA routing. It logs requests and supports binding to specific interfaces or ports.
Ideal for local development, testing front-end apps, or quick file sharing without full web servers like Apache or Nginx. No setup needed beyond installation; highly portable across platforms including Linux.
Usage starts in a project directory: http-server serves the current folder. Customize with flags for production-like setups during dev.
CAVEATS
Not a native Linux command; requires Node.js (≥14) and npm. Install globally: npm install -g http-server. Runs as user process, not daemonized. For production, use dedicated servers like Nginx.
INSTALLATION
npm install --global http-server
Then run http-server in any directory.
BASIC EXAMPLE
http-server -p 3000 -o -w
Serves on port 3000, opens browser, watches files.
HTTPS EXAMPLE
http-server -S --cert cert.pem --key key.pem
Generates self-signed certs if paths omitted.
HISTORY
Created in 2011 by Charlie Robbins (indexzero) as a Node.js static file server. Evolved from node-static; current version (~14.x) maintained by community on npm with 20M+ weekly downloads. Key updates: Brotli support (v13+), better SPA handling.
SEE ALSO
python3 -m http.server(1), php -S(1), busybox httpd(8), nginx(8)


