This guide covers advanced networking, protocol, and TLS options in fetch.
Use a custom DNS server instead of the system resolver.
Specify an IP address with optional port:
# Google DNS
fetch --dns-server 8.8.8.8 example.com
# Cloudflare DNS with custom port
fetch --dns-server 1.1.1.1:53 example.com
# IPv6 DNS server
fetch --dns-server "[2001:4860:4860::8888]:53" example.comUse HTTPS URL for encrypted DNS queries:
# Cloudflare DoH
fetch --dns-server https://1.1.1.1/dns-query example.com
# Google DoH
fetch --dns-server https://dns.google/dns-query example.com
# Quad9 DoH
fetch --dns-server https://dns.quad9.net/dns-query example.com# Use Cloudflare DNS globally
dns-server = 1.1.1.1
# Use DoH for specific hosts
[secure.example.com]
dns-server = https://1.1.1.1/dns-queryRoute requests through a proxy server.
fetch --proxy http://proxy.example.com:8080 example.comfetch --proxy https://secure-proxy.example.com:8443 example.comfetch --proxy socks5://localhost:1080 example.comfetch --proxy http://user:password@proxy.example.com:8080 example.comfetch respects standard proxy environment variables:
export HTTP_PROXY="http://proxy.example.com:8080"
export HTTPS_PROXY="http://proxy.example.com:8080"
export NO_PROXY="localhost,127.0.0.1,.internal.com"
fetch example.com # Uses proxy from environment# Global proxy
proxy = http://proxy.example.com:8080
# Host-specific proxy
[internal.example.com]
proxy = socks5://internal-proxy:1080Connect via Unix domain socket instead of TCP. Available on Unix-like systems only.
fetch --unix /var/run/docker.sock http://localhost/containers/json
fetch --unix /var/run/docker.sock http://localhost/images/jsonfetch --unix /var/run/myservice.sock http://localhost/api/status
fetch --unix ~/myapp.sock http://localhost/healthNote: The hostname in the URL is ignored when using Unix sockets; the socket path determines the destination.
Force a specific HTTP version.
fetch --http 1 example.com- Uses HTTP/1.1 protocol
- Single request per connection
- No header compression
- Useful for debugging or legacy servers
fetch --http 2 example.com- Default behavior (HTTP/2 preferred with fallback)
- Multiplexed streams
- Header compression (HPACK)
- Required for gRPC
- Automatically uses h2c (HTTP/2 over cleartext) for gRPC requests with
http://URLs, enabling plaintext HTTP/2 connections to local development servers without TLS
fetch --http 3 example.com- Uses QUIC transport (UDP-based)
- Reduced latency
- Better handling of packet loss
- Not all servers support HTTP/3
By default, fetch negotiates the best available version:
- Attempts HTTP/2 via ALPN
- Falls back to HTTP/1.1 if needed
--tls VERSION sets the minimum acceptable TLS version:
fetch --tls 1.2 example.com # Require TLS 1.2+
fetch --tls 1.3 example.com # Require TLS 1.3| Value | Protocol |
|---|---|
1.0 |
TLS 1.0 (legacy) |
1.1 |
TLS 1.1 (deprecated) |
1.2 |
TLS 1.2 (recommended minimum) |
1.3 |
TLS 1.3 (most secure) |
--insecure accepts invalid TLS certificates:
fetch --insecure https://self-signed.example.comWarning: Only use for development/testing. Never in production.
--ca-cert specifies a custom CA certificate:
fetch --ca-cert /path/to/ca.crt https://internal.example.comUse cases:
- Internal PKI with private CA
- Development with self-signed certificates
- Corporate environments with SSL inspection
--inspect-tls performs a TLS handshake only (no HTTP request is made) and provides a focused view of the TLS certificate chain, useful as a standalone diagnostic tool:
fetch --inspect-tls example.comOutput includes:
- TLS version and cipher suite (e.g., TLS 1.3: TLS_AES_256_GCM_SHA384)
- ALPN negotiated protocol (e.g., h2)
- Certificate chain with tree visualization and expiry status
- Subject Alternative Names (DNS names and IP addresses)
- OCSP staple status (good, revoked, or unknown)
Expiry is color-coded: red if expired or less than 7 days remaining, yellow if less than 30 days, green otherwise.
HTTP-only flags (e.g. --data, --timing, --grpc) are ignored with a warning when used with --inspect-tls.
# Check certificate chain
fetch --inspect-tls example.com
# Inspect certificates even if invalid
fetch --inspect-tls --insecure expired.badssl.com# Require TLS 1.2 minimum
tls = 1.2
# Internal server with private CA
[internal.company.com]
ca-cert = /etc/pki/internal-ca.crt
# Development server (insecure)
[dev.localhost]
insecure = trueDisable automatic compression negotiation:
fetch --no-encode example.comBy default, fetch:
- Sends
Accept-Encoding: gzip, zstdheader - Automatically decompresses responses
Disabling is useful when:
- Testing compression behavior
- Server has compression bugs
- You want to see raw compressed data
Request specific byte ranges (partial content):
# First 1KB
fetch -r 0-1023 example.com/file.bin
# Last 500 bytes
fetch -r -500 example.com/file.bin
# Skip first 1000 bytes
fetch -r 1000- example.com/file.binfetch -r 0-499 -r 1000-1499 example.com/file.binThis sets the header:
Range: bytes=0-499, 1000-1499
- Resume interrupted downloads
- Download specific portions of large files
- Video seeking
- Parallel downloads
Set maximum number of automatic redirects:
# Disable redirects
fetch --redirects 0 example.com
# Allow up to 10 redirects
fetch --redirects 10 example.comfetch -v --redirects 5 example.comShows each redirect hop with status codes.
Set a timeout for the entire request:
fetch --timeout 30 example.com
fetch --timeout 2.5 example.com # Decimal secondsThe timeout covers:
- DNS resolution
- Connection establishment
- TLS handshake
- Request/response transfer
Set a timeout for just the connection phase (DNS resolution, TCP connect, TLS handshake):
fetch --connect-timeout 5 example.com
fetch --connect-timeout 5 --timeout 30 example.com # Both timeoutsThis is useful for fast-failing on unreachable hosts while allowing large responses to transfer slowly. The connect timeout is independent of --timeout — both can be set simultaneously, and --timeout still caps the entire request.
# Global timeout
timeout = 30
# Connect timeout for fast-fail on unreachable hosts
connect-timeout = 5
# Longer timeout for slow API
[slow-api.example.com]
timeout = 120Complex requests often combine multiple advanced options:
fetch \
--dns-server https://1.1.1.1/dns-query \
--proxy socks5://localhost:9050 \
--tls 1.3 \
--timeout 60 \
--http 2 \
-v \
https://example.onion/api# Global settings
timeout = 30
tls = 1.2
dns-server = 8.8.8.8
# Internal services
[internal.company.com]
proxy = http://internal-proxy:8080
ca-cert = /etc/pki/internal-ca.crt
insecure = false
# Development environment
[localhost]
insecure = true
timeout = 5
# High-security API
[secure-api.example.com]
tls = 1.3
timeout = 60Persistent cookie storage across invocations using named sessions.
# First request — server sets cookies, they get saved
fetch --session api https://example.com/login -j '{"user":"me"}'
# Second request — saved cookies are sent automatically
fetch --session api https://example.com/dashboardDifferent session names maintain separate cookie stores:
fetch --session prod https://api.example.com/login
fetch --session staging https://staging.example.com/loginSet session names per-host so you don't need --session every time:
# Global default session
session = default
# Per-host session names
[api.example.com]
session = api-prod
[staging.example.com]
session = api-stagingSessions are stored as JSON in the user's cache directory:
- Linux:
~/.cache/fetch/sessions/<NAME>.json - macOS:
~/Library/Caches/fetch/sessions/<NAME>.json
- Expired cookies: Cookies with an explicit expiry in the past are filtered out on load.
- Session cookies (no explicit expiry): Persist across invocations since the session is explicitly named.
- Cookie domain matching: Delegated to Go's
net/http/cookiejar, which implements RFC 6265. - Atomic writes: Session files are written atomically (temp file + rename) to avoid corruption.
- Name validation: Only
[a-zA-Z0-9_-]characters are allowed to prevent path traversal.
--timing (or -T) displays a timing waterfall chart after the response, showing how time was spent across DNS resolution, TCP connection, TLS handshake, time to first byte, and body download:
fetch --timing https://example.comThe chart adapts to the request: TLS is omitted for HTTP, TCP is omitted for HTTP/3 (QUIC), and DNS/TCP/TLS are omitted when the connection is reused. Combine with -vvv for both inline debug text and the waterfall summary.
Can also be configured in the configuration file:
timing = truefetch -v example.com # Response headers
fetch -vv example.com # Request + response headers with direction prefixes
fetch -vvv example.com # DNS + TLS details with direction prefixesPreview the request without sending:
fetch --dry-run -m POST -j '{"test": true}' example.com# Test with specific DNS
fetch --dns-server 8.8.8.8 -v example.com
# Test with explicit HTTP version
fetch --http 1 -v example.com
# Test TLS configuration
fetch --tls 1.3 -vvv example.com- CLI Reference - Complete option reference
- Authentication - mTLS and other auth methods
- Configuration - Configuration file options
- Troubleshooting - Network debugging