Skip to content

Environment Variables

The .env file stores sensitive credentials and system-level settings.

PlatformPath
macOS/Linux~/.config/nextdns-blocker/.env
Windows%APPDATA%\nextdns-blocker\.env

Your NextDNS API key for authentication.

Terminal window
NEXTDNS_API_KEY=abcdef1234567890

How to get it:

  1. Go to my.nextdns.io/account
  2. Scroll to “API” section
  3. Click to reveal and copy

Requirements:

  • Minimum 8 characters
  • Alphanumeric

Your NextDNS profile identifier.

Terminal window
NEXTDNS_PROFILE_ID=abc123

How to get it:

  1. Go to my.nextdns.io
  2. Select your profile
  3. Copy from URL: https://my.nextdns.io/abc123/setup

Requirements:

  • 4-30 characters
  • Alphanumeric

Request timeout in seconds.

Terminal window
API_TIMEOUT=10
ValueDefaultDescription
5-Fast timeout, may fail on slow connections
10Balanced default
30-For slow/unreliable connections

Number of retry attempts on failure.

Terminal window
API_RETRIES=3
ValueDefaultDescription
1-Fail fast
3Balanced default
5-Maximum retry effort

Retries use exponential backoff (1s, 2s, 4s, etc.).

Maximum API requests per time window.

Terminal window
RATE_LIMIT_REQUESTS=30
ValueDefaultDescription
10-Conservative
30Balanced
60-High-frequency sync

Time window for rate limiting in seconds.

Terminal window
RATE_LIMIT_WINDOW=60
ValueDefaultDescription
30-Stricter limiting
60Standard window
120-More permissive

How long to cache denylist data in seconds.

Terminal window
CACHE_TTL=60
ValueDefaultDescription
30-Fresher data, more API calls
60Balanced
300-Fewer API calls
Terminal window
# Required - NextDNS Credentials
NEXTDNS_API_KEY=your_api_key_here
NEXTDNS_PROFILE_ID=abc123
# Optional - API Settings
API_TIMEOUT=10
API_RETRIES=3
# Advanced - Rate Limiting (usually not needed)
# RATE_LIMIT_REQUESTS=30
# RATE_LIMIT_WINDOW=60
# CACHE_TTL=60

The .env file is created with restricted permissions (0600):

Terminal window
# Check permissions
ls -la ~/.config/nextdns-blocker/.env
# Should show: -rw------- (owner read/write only)
# Fix permissions if needed
chmod 600 ~/.config/nextdns-blocker/.env

Never commit .env to version control. It’s included in .gitignore:

.env
*.env

Variables can also be set in your shell environment:

Terminal window
export NEXTDNS_API_KEY=your_key
nextdns-blocker config push

Priority order:

  1. Shell environment variables
  2. .env file in config directory
  3. Default values
Terminal window
nextdns-blocker init

The setup wizard validates credentials against the NextDNS API.

Terminal window
# Test API key
curl -H "X-Api-Key: YOUR_API_KEY" https://api.nextdns.io/profiles
# Should return your profiles, not an error
  1. Check for extra whitespace in .env
  2. Regenerate API key at my.nextdns.io/account
  3. Verify key is correct (copy/paste carefully)
  1. Check profile ID matches URL exactly
  2. Verify profile exists at my.nextdns.io
  3. Check API key has access to profile
  1. Increase API_TIMEOUT:
    Terminal window
    API_TIMEOUT=30
  2. Check internet connection
  3. Check NextDNS service status