This guide provides comprehensive documentation for configuring fetch using a configuration file.
fetch uses an INI-like configuration file format that supports both global and host-specific settings.
fetch searches for configuration files in the following order:
- Specified path: The file location specified with the
-cor--configflag - Default path candidates:
$XDG_CONFIG_HOME/fetch/config(ifXDG_CONFIG_HOMEis set)$HOME/.config/fetch/config(ifHOMEis set)- Windows only:
%AppData%\fetch\config(fallback)
On Windows, fetch still checks XDG_CONFIG_HOME and HOME first when those
environment variables are present, then falls back to %AppData%\fetch\config.
Scalar settings are applied in the following order of precedence (highest to lowest):
- Command line flags - Override all other settings
- Domain-specific configuration - Host-specific settings in config file
- Global configuration - Global settings in config file
- Default values - Built-in application defaults
In summary, scalar options override other scalar options. List options merge in
this order: global, host, and CLI.
Repeatable options such as header, query, and ca-cert are applied in this
order: global config first, then the matched host section, then command-line
flags.
As a result, you can set global defaults and override scalar values for each domain or command. You can also add shared list values without removing more specific entries.
Configuration files use a simple key-value format with optional sections:
# Global settings
option = value
# Host-specific settings
[example.com]
option = host_specific_valueType: Boolean or duration interval
Default: false (disabled)
Enable or disable automatic updates, or set the minimum interval between update checks. See Updates for background update behavior, cache files, locking, verification, and timeout/proxy behavior.
# Enable auto-update with default 24-hour interval
auto-update = true
# Disable auto-update
auto-update = false
# Custom update interval
auto-update = 4h
auto-update = 1.5h
auto-update = 30m
auto-update = +30m
auto-update = 1dType: Boolean
Default: false
Copy the response body to the system clipboard.
copy = true
copy = falseType: String
Values: auto, off, on
Default: auto
Control colored output in the terminal.
# Automatically detect terminal color support
color = auto
# Always disable colors
color = off
# Always enable colors
color = onType: String
Values: auto, off, on
Default: auto
Control automatic formatting of response bodies (JSON, XML, etc.).
# Automatically detect and format supported content types
format = auto
# Disable all formatting
format = off
# Always attempt formatting
format = onType: String
Values: auto, external, off
Default: auto
Control image rendering in the terminal.
# Try optimal terminal protocol with built-in decoders
image = auto
# Allow external adapters for additional formats
image = external
# Disable image rendering
image = offType: String
Values: auto, on, off
Default: auto
Control piping response body output through a pager. auto uses the pager when
stdout is a terminal, on forces pager use, and off disables the pager. When
paging is enabled, fetch uses $PAGER if it is set. Set NO_PAGER to disable
the default auto pager. If $PAGER is unset, fetch uses less -FIRX.
If $LESS is set, fetch runs less without its default flags. Your LESS
options still apply. $PAGER is split with POSIX shell-style quoting, but
fetch launches the pager directly and does not interpret shell operators such as
pipes or redirects.
# Disable pager
pager = off
# Force pager
pager = onType: Boolean
Default: false
Suppress verbose output. Only errors are written to stderr.
# Enable silent mode
silent = true
# Normal output (default)
silent = falseType: Boolean
Default: false
Display a timing waterfall chart after the response, showing DNS, TCP, TLS, TTFB, and body download phases.
# Enable timing waterfall
timing = true
# Disable timing waterfall (default)
timing = falseType: Integer
Values: 0 or greater
Default: 0
Set the verbosity level for debug output.
# Normal output (default)
verbosity = 0
# Verbose - show response headers
verbosity = 1
# Extra verbose - show request and response headers with direction prefixes
verbosity = 2
# Debug - show DNS and TLS details with direction prefixes
verbosity = 3Type: Boolean
Default: false
Sort displayed request and response headers alphabetically by name. This only
changes verbose output. fetch sends request headers in their normal order.
sort-headers = trueType: CA certificate path Repeatable: Yes Default: System default
Use a custom CA cert pool.
# Set to filepath to cert file
ca-cert = ca-cert.pem
# Multiple custom roots are appended in order
ca-cert = internal-root.pem
ca-cert = partner-root.pemType: IP[:PORT], udp://IP[:PORT], tcp://IP[:PORT], tls://HOST[:PORT],
dot://HOST[:PORT], quic://HOST[:PORT], doq://HOST[:PORT], or HTTPS URL
Default: System default
Use a custom DNS server for hostname resolution.
DoH URLs use RFC 8484 wire-format requests, with Google-style JSON DoH retained as a compatibility fallback.
# Use Google DNS
dns-server = 8.8.8.8
# Use Cloudflare DNS with custom port
dns-server = 1.1.1.1:53
# Use IPv6 DNS server
dns-server = [2001:4860:4860::8888]:53
# DNS over TCP
dns-server = tcp://1.1.1.1
# DNS over TLS
dns-server = tls://dns.google
# DNS over QUIC
dns-server = doq://dns.adguard-dns.com
# Use DNS-over-HTTPS
dns-server = https://1.1.1.1/dns-query
dns-server = https://dns.google/dns-queryType: URL Default: None
Route requests through the specified proxy server.
# HTTP proxy
proxy = http://proxy.example.com:8080
# HTTPS proxy
proxy = https://secure-proxy.example.com:8080
# SOCKS5 proxy
proxy = socks5://localhost:1080Type: Number (seconds) Default: None (no connect timeout)
Set a timeout for the connection phase (DNS resolution, TCP connect, TLS handshake). Independent of timeout, which covers the entire request. Accepts decimal values.
# 5 second connect timeout
connect-timeout = 5
# 2.5 second connect timeout
connect-timeout = 2.5Type: Number (seconds) Default: None (no timeout)
Set a timeout for HTTP requests. Accepts decimal values. This timeout covers the full request, including streamed response bodies such as SSE, NDJSON, and gRPC streams.
# 30 second timeout
timeout = 30
# 2.5 second timeout
timeout = 2.5Type: Integer
Default: 10
Set the maximum number of automatic redirects to follow.
# Disable redirects
redirects = 0
# Allow up to 10 redirects
redirects = 10Type: Integer
Default: 0 (no retries)
Maximum number of retries for transient failures. Retries occur on connection errors and retryable status codes (429, 502, 503, 504).
# Retry up to 3 times
retry = 3
# Disable retries (default)
retry = 0Type: Number (seconds)
Default: 1
Initial delay between retries in seconds. Uses exponential backoff with jitter. Accepts decimal values.
# 2 second initial delay
retry-delay = 2
# 500ms initial delay
retry-delay = 0.5Type: String
Values: 1, 2, 3
Force a specific HTTP protocol version.
When unset, direct HTTPS requests use DNS HTTPS/SVCB records to discover h3
endpoints. With dns-server, HTTPS-record discovery uses that custom UDP, TCP,
DoT, DoQ, or DoH resolver. Without dns-server, it uses the platform resolver.
On Linux, this uses systemd-resolved when available. The documented Unix
resolver-file fallback cannot honor NSS or split-DNS policy. Discovery runs in
parallel with normal A/AAAA
lookup and TCP/TLS setup. fetch starts TCP/TLS as soon as normal DNS produces a usable
address, while a usable h3 record discovered before TCP/TLS wins races QUIC
setup against it. The request is sent once on the winning transport. System,
UDP, TCP, and plaintext HTTP DNS can fall back after an HTTPS-record lookup
failure. A transport, server, or malformed-response failure from
certificate-verified DoH, DoT, or DoQ stops the connection to prevent protocol
downgrade. Authenticated NODATA and NXDOMAIN results can use the normal ALPN
path. Proxy and Unix socket requests also use the normal ALPN path.
Setting this option to 1, 2, or 3 forces that protocol. It does not set a
version cap. Set http = 1 or http = 2 to opt out of automatic HTTP/3.
Forced HTTP/2 with a plain http:// URL is only supported for gRPC requests,
where fetch uses h2c (HTTP/2 over cleartext).
# Force HTTP/1.1
http = 1
# Force HTTP/2
http = 2Type: String
Values: 1.2, 1.3
Default: 1.2
Specify the minimum TLS version to use. This is an alias for min-tls.
# Require TLS 1.2 or higher
tls = 1.2
# Require TLS 1.3 or higher
tls = 1.3Type: String
Values: 1.2, 1.3
Default: 1.2
Specify the minimum TLS version to use.
min-tls = 1.2Type: String
Values: 1.2, 1.3
Default: No maximum
Specify the maximum TLS version to use. Set min-tls and max-tls to the same value to require an exact TLS version.
# Require exactly TLS 1.2
min-tls = 1.2
max-tls = 1.2Type: String
Values: auto, on, off
Default: off
Enable Encrypted Client Hello (ECH). When set to auto, ECH is used if the
server advertises it in DNS. When set to on, ECH is required.
See Encrypted Client Hello for details.
# Auto-detect ECH
ech = auto
# Require ECH
ech = onType: Boolean
Default: false
Allow connections to servers with invalid TLS certificates.
# Allow invalid certificates (not recommended)
insecure = true
# Require valid certificates (default)
insecure = falseType: File path Default: None
Specify the path to a client certificate file for mTLS authentication. Use PEM
format. If the file contains the certificate and private key, you do not need a
separate key option.
# Client certificate for mTLS
cert = /path/to/client.crt
# Combined certificate and key file
cert = /path/to/client.pemType: File path Default: None
Specify the path to a client private key file for mTLS authentication. Use PEM
format. This option is required if cert points to a certificate-only file.
# Client private key for mTLS
key = /path/to/client.keymTLS Example Configuration:
# Global mTLS settings
cert = /path/to/default-client.crt
key = /path/to/default-client.key
# Host-specific mTLS for API server
[api.secure.example.com]
cert = /path/to/api-client.crt
key = /path/to/api-client.key
ca-cert = /path/to/api-ca.crtOperation:
- If you specify
certwithoutkey,fetchreads the private key from the certificate file. - If
fetchdoes not find the private key, it reports an error. - TLS requests reject
keywithoutcert. fetchdoes not support encrypted private keys.
Type: String
Default: auto
Control automatic compression negotiation and decompression.
# Request gzip, brotli, or zstd compression (default)
compress = auto
# Request one algorithm only
compress = br
# The brotli alias is also accepted:
compress = brotli
compress = gzip
compress = zstd
# Disable compression negotiation
compress = offOutput files receive decoded/decompressed bodies by default too. Use
compress = off or --compress off for byte-for-byte downloads of .gz,
.br, or .zst assets.
With compress = auto, fetch retries compressed SSE (text/event-stream)
responses to GET and HEAD requests without Accept-Encoding. For other
methods, it keeps the compressed response and gives a warning. For immediate
SSE streaming with another method, set compress = off.
Type: String Default: None
Set a named session to keep cookies for subsequent commands. fetch saves
server cookies to disk. It sends the cookies in subsequent requests that use
the same session name. Use only alphanumeric characters, hyphens, and
underscores in the name.
# Global default session
session = default
# Per-host session names
[api.example.com]
session = api-prod
[staging.example.com]
session = api-stagingCLI --session flag overrides the config value. See CLI Reference for more details.
Type: String (name:value format) Repeatable: Yes
Set custom HTTP headers. Repeat this option to set multiple headers.
# Single header
header = X-API-Key: your-api-key
# Multiple headers
header = X-Custom-Header: value1
header = Authorization: Bearer token
header = User-Agent: MyApp/1.0Type: String (key=value format) Repeatable: Yes
Append query parameters to requests. Repeat this option to append multiple parameters.
# Single query parameter
query = api_version=2
# Multiple query parameters
query = page=1
query = limit=50
query = sort=nameType: Boolean
Default: false
HTTP 4xx/5xx responses exit nonzero by default. Set ignore-status = true to
ignore HTTP status when choosing the exit code.
# Ignore HTTP status for exit code
ignore-status = true
# Use HTTP status for exit code (default)
ignore-status = falseUse sections to configure different settings for specified hosts or domains:
# Global settings apply to all requests
timeout = 30
color = auto
# Settings for api.example.com
[api.example.com]
timeout = 10
header = X-API-Key: secret-key-for-api
query = version=2
# Settings for internal.company.com
[internal.company.com]
insecure = true
proxy = http://internal-proxy:8080
header = Authorization: Bearer internal-token
# Settings for slow.example.com
[slow.example.com]
timeout = 120
redirects = 0Use the [*.domain.com] syntax to match all subdomains of a domain:
# Match any subdomain of example.com
[*.example.com]
header = X-API-Key: shared-key
# Match any subdomain of api.example.com (more specific)
[*.api.example.com]
header = X-API-Key: api-specific-key
# Exact match always takes priority
[admin.example.com]
header = X-API-Key: admin-keyMatching rules:
*.example.commatchesapi.example.comanda.b.example.com.*.example.comdoes not matchexample.comitself- Exact matches always take priority over wildcard matches
- When multiple wildcards match, the most specific (longest suffix) wins
- Only one host config section is applied per request (no merging across sections)
- Use the exact hostname, without the protocol or path, as the section name.
Alternatively, use a wildcard pattern such as
*.domain.com. - Duplicate host section names are rejected. Names are compared case-insensitively after trimming, so
[API.example.com]and[api.example.com]are duplicates. - Scalar host-specific settings override global settings
- Scalar command-line flags override both global and host-specific settings
- List settings such as
header,query, andca-certmerge in order: global first, then the matched host section, then command-line flags
# Enable colored output and formatting
color = on
format = on
# Set reasonable timeouts
timeout = 30
redirects = 5
# Enable auto-update checks every 12 hours
auto-update = 12h
# Add common headers
header = User-Agent: fetch/1.0# Global API settings
format = on
color = on
timeout = 10
# Development API
[api.dev.example.com]
header = X-API-Key: dev-key-here
header = X-Environment: development
query = debug=1
# Production API (more restrictive)
[api.example.com]
header = X-API-Key: prod-key-here
timeout = 30
redirects = 3# Corporate proxy settings
proxy = http://corporate-proxy.company.com:8080
# Internal services (allow self-signed certificates)
[internal.company.com]
insecure = true
# External APIs (strict security)
[external-api.vendor.com]
min-tls = 1.2
timeout = 60
header = X-Company-ID: company-identifierfetch validates configuration files when it loads them. It reports errors in
this format:
config file '/home/user/.config/fetch/config': line 15: invalid option: 'invalid-option'
The tool reports these types of validation error:
- Invalid option names
- Invalid values for specified options, such as
color = invalid - Malformed key=value pairs
- Empty host section names
[]
- Use host-specific sections for API keys and service-specific settings.
- Set applicable timeouts to prevent requests from running too long.
- Use global settings for common preferences such as color and formatting.
- Keep configuration files secure. They can contain API keys.
- Test configurations with dry-run mode:
fetch --dry-run example.com. - Use comments to document complex configurations.
- Enable automatic updates to get security and feature updates.
- CLI Reference - All command-line options
- Authentication - Detailed authentication setup
- Advanced Features - DNS, proxies, and TLS configuration
- Updates - Manual and automatic update behavior