Available Flags
Server host to connect/control (e.g.,
127.0.0.1:1700)Environment Variable: SURGE_HOSTWhen specified, the CLI will connect to a remote or local Surge server instead of starting a new instance. This is useful for controlling headless servers or remote instances.Bearer token for API authenticationEnvironment Variable:
SURGE_TOKENRequired when connecting to a server with authentication enabled. If not provided via flag or environment variable, Surge will attempt to read the token from the local token file.Enable verbose loggingShort flag:
-vWhen enabled, Surge will output detailed debug information to help troubleshoot issues. Logs are written to the logs directory.Command-Specific Flags
The following flags are available for the root command (surge [url]...) and surge server:
File containing URLs to download (one per line)Short flag: Example batch file:
-bAccepts a file path containing URLs to download. Each URL should be on its own line. Lines starting with # are treated as comments and ignored.Port to listen on for HTTP APIShort flag:
-pSpecifies the port for the HTTP server. If set to 0 (default), Surge will automatically find an available port starting from 1700.The selected port is saved to the runtime directory and used by the browser extension and CLI for autodiscovery.
Default output directory for downloadsShort flag:
-oSpecifies where downloaded files should be saved. If not provided, uses the default_download_dir from settings.json, or the current directory as a fallback.Do not auto-resume paused downloads on startupBy default, Surge respects the
auto_resume setting in settings.json. This flag overrides that behavior and prevents automatic resumption of paused downloads.Exit when all downloads completeUseful for automation and scripting. Surge will automatically quit when all active downloads finish.
Flag Priority
When both a command-line flag and environment variable are set, the command-line flag takes precedence:- Command-line flag (highest priority)
- Environment variable
- Configuration file
- Default value (lowest priority)