CLI Options
serve
provides a rich set of command-line options to customize its behavior. You can view all available options by running serve --help
.
This page provides a detailed breakdown of each option.
--help
Shows the help message, which includes usage instructions and a list of all available options.
- Usage:
serve --help
-v
, --version
Displays the currently installed version of serve
.
- Usage:
serve -v
-l
, --listen <uri>
Specify one or more URI endpoints for the server to listen on. This is a powerful option that allows you to listen on TCP ports, UNIX domain sockets, or Windows named pipes.
This option can be used multiple times to listen on multiple endpoints simultaneously.
-
Usage:
# Listen on port 5000 serve -l 5000 # Listen on a specific host and port serve -l tcp://192.168.1.5:8080 # Listen on a UNIX socket serve -l unix:/tmp/serve.sock
-
For more details, see the Advanced Endpoints documentation.
-p <port>
Specify a custom port to listen on. This is a legacy alias for -l <port>
.
- Usage:
serve -p 5000
-s
, --single
Rewrites all requests that would otherwise result in a 404 Not Found
to /index.html
. This is essential for single-page applications (SPAs) that use client-side routing.
- Usage:
serve -s
-d
, --debug
Enables debug mode, which shows more detailed information in case of errors, such as a full stack trace if an update check fails.
- Usage:
serve -d
-c
, --config <path>
Specify a custom path to a configuration file. By default, serve
looks for serve.json
in the directory being served.
- Usage:
serve -c my-config.json
- See the Configuration documentation for more details.
-L
, --no-request-logging
Disables the logging of incoming request information (IP address, method, URL, status code, response time) to the console.
- Usage:
serve -L
-C
, --cors
Enables Cross-Origin Resource Sharing (CORS) by setting the Access-Control-Allow-Origin
header to *
and adding other necessary CORS headers.
- Usage:
serve -C
-n
, --no-clipboard
Prevents serve
from automatically copying the local server address to your clipboard upon startup.
- Usage:
serve -n
-u
, --no-compression
Disables Gzip/Brotli compression for file responses.
- Usage:
serve -u
--no-etag
Disables ETag headers and sends the Last-Modified
header instead for caching control.
- Usage:
serve --no-etag
-S
, --symlinks
Resolves symbolic links in the file system instead of treating them as non-existent and returning a 404 error.
- Usage:
serve -S
--ssl-cert <path>
Specifies the path to an SSL/TLS certificate file to enable serving content over HTTPS.
- Supported Formats: PEM (default), PKCS12 (PFX,
.pfx
,.p12
). - Usage:
serve --ssl-cert path/to/cert.pem
- For detailed instructions, see the Serving with HTTPS/SSL guide.
--ssl-key <path>
Specifies the path to the private key for the SSL/TLS certificate. This is only required for PEM-formatted certificates.
- Usage:
serve --ssl-cert cert.pem --ssl-key key.pem
--ssl-pass <passphrase>
Specifies the passphrase for the SSL/TLS certificate or private key, if it is encrypted.
- Usage:
serve --ssl-cert cert.pfx --ssl-pass mysecret
--no-port-switching
If the specified port is already in use, serve
will exit instead of automatically trying to find another available port.
- Usage:
serve --no-port-switching -l 3000