Set SENTRY_URL to point to your self-hosted Sentry instance:
export SENTRY_URL=https://sentry.example.com
This variable affects:
API requests (all commands)
OAuth device flow (authentication)
Web UI URLs (opened in browser)
macOS/Linux
Windows (PowerShell)
Windows (CMD)
Docker/CI
.bashrc or .zshrc
# Add to your shell profileexport SENTRY_URL=https://sentry.example.com
Then reload your shell:
source ~/.bashrc # or ~/.zshrc
# Set for current session$env:SENTRY_URL = "https://sentry.example.com"# Set permanently (user level)[System.Environment]::SetEnvironmentVariable( 'SENTRY_URL', 'https://sentry.example.com', 'User')
# Set for current sessionset SENTRY_URL=https://sentry.example.com# Set permanentlysetx SENTRY_URL "https://sentry.example.com"
For OAuth authentication on self-hosted instances, you must create an OAuth application and set SENTRY_CLIENT_ID:
1
Create an OAuth Application
Log in to your self-hosted Sentry instance
Go to Settings > Developer Settings
Click Create New Application
Set application name (e.g., “Sentry CLI”)
Set Application Type to Public
Set Redirect URIs to http://localhost (required but unused for device flow)
Click Save
Copy the Client ID
2
Set the environment variable
export SENTRY_CLIENT_ID=your-client-id-here
Add this to your shell profile alongside SENTRY_URL.
3
Authenticate
sentry auth login
The CLI will use your self-hosted instance for the OAuth flow.
Example: Complete self-hosted setup
# Set base URLexport SENTRY_URL=https://sentry.example.com# Set OAuth client ID (from Developer Settings)export SENTRY_CLIENT_ID=abc123def456# Authenticatesentry auth login# Use CLI normallysentry issue listsentry project list
When SENTRY_URL is set, the CLI only detects DSNs matching your self-hosted instance:
# With SENTRY_URL=https://sentry.example.com# This DSN is detected:# https://[email protected]/4505238# This DSN is ignored (different host):# https://[email protected]/4505238
This prevents mixing SaaS and self-hosted DSNs, which would cause API errors.
If you work with multiple Sentry instances, use separate shells or shell aliases with different SENTRY_URL values.
By default, the CLI stores authentication and cache data in ~/.sentry/.For self-hosted instances, you might want separate configuration directories:
# Use a separate config directory for self-hostedexport SENTRY_CONFIG_DIR=~/.sentry-selfhostedexport SENTRY_URL=https://sentry.example.comsentry auth login
This keeps SaaS and self-hosted credentials separate.