LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

http-server

simple static file server

TLDR

Start server
$ http-server
copy
Specify port
$ http-server -p [8080]
copy
Specify directory
$ http-server [./public]
copy
Enable CORS
$ http-server --cors
copy
Enable gzip
$ http-server -g
copy
SSL server
$ http-server -S -C [cert.pem] -K [key.pem]
copy

SYNOPSIS

http-server [options] [path]

DESCRIPTION

http-server is a simple, zero-configuration static file server for Node.js. It serves files from a directory over HTTP, making it ideal for quickly testing frontend builds, sharing files on a local network, or previewing static sites.Install via `npm install -g http-server`. Serves the current directory by default on port 8080.

PARAMETERS

PATH

Directory to serve.
-p, --port PORT
Port number (default 8080).
-a ADDRESS
Listen address.
-c SECONDS
Cache time.
--cors
Enable CORS headers.
-g, --gzip
Enable gzip.
-S, --ssl
Enable SSL.
-C FILE
SSL certificate file (default: cert.pem).
-K FILE
SSL key file (default: key.pem).
-o
Open browser after starting.
-P, --proxy URL
Proxy unresolvable requests to this URL.
--no-dotfiles
Do not serve dotfiles.

CAVEATS

Requires Node.js and npm. Not suitable for production use — provides no authentication, rate limiting, or hardened security. For production static file serving, use nginx or a CDN.

HISTORY

http-server is a popular npm package for quickly serving static files during development.

SEE ALSO

serve(1), python(1), live-server(1)

Copied to clipboard
Kai