We're getting HTTP 401 Unauthorized when the Elixir Sentry SDK attempts to send events to BetterStack's Sentry-compatible endpoint. The SDK successfully sends the events, but BetterStack rejects them with authentication errors.
- Elixir: 1.17+
- Sentry SDK:
{:sentry, "~> 11.0.4"} - Client:
Sentry.HackneyClient - Environment: Development (same issue expected in production)
BetterStack provides two different DSN formats in different locations, and both fail with 401 Unauthorized:
Source: https://betterstack.com/docs/errors/collecting-errors/sentry-sdk/?application=1592187
Format:
https://SC36ZjS3KTUCypm***********@s1592187.eu-nbg-2.betterstackdata.com/1
Structure:
- Host includes application ID as subdomain:
s[app-id].eu-nbg-2.betterstackdata.com - Project ID at end:
/1
Source: https://errors.betterstack.com/team/t*****/applications/1592187/data-ingestion
Format:
https://SC36ZjS3KTUCypm***********@eu-nbg-2.betterstackdata.com/1592187
Structure:
- Generic host:
eu-nbg-2.betterstackdata.com - Application ID as project:
/1592187
Both formats produce identical 401 errors.
Following the official Sentry Elixir documentation, we have a minimal vanilla config:
# Vanilla Sentry setup - minimal configuration per Sentry docs
config :sentry,
dsn: System.get_env("SENTRY_DSN"),
environment_name: config_env(),
enable_source_code_context: true,
root_source_code_paths: [File.cwd!()],
client: Sentry.HackneyClient,
send_result: :sync # For debugging# We tested BOTH DSN formats - both fail with 401
SENTRY_DSN=https://[key]@[host]/[project]Following the Sentry Elixir documentation example:
# Test 1: Simple message (from Sentry docs)
Sentry.capture_message("Hello Better Stack, this is a test message from Elixir!")
# Test 2: Exception with stacktrace (from Sentry docs)
try do
raise "This is a test exception from Elixir!"
rescue
exception ->
Sentry.capture_exception(exception, stacktrace: __STACKTRACE__)
endBoth DSN formats produce identical 401 errors for both test cases:
[warning] Failed to send Sentry event. Sentry failed to report event:
the Sentry server responded with an error, the details are below.
HTTP Status: 401
Response Headers: [
{"content-type", "application/json"},
{"access-control-allow-origin", "*"},
{"access-control-allow-methods", "GET, POST, OPTIONS, HEAD"},
{"access-control-allow-headers", "*"},
{"content-length", "25"},
{"date", "Tue, 18 Nov 2025 06:55:13 GMT"}
]
Response Body: "{\"error\": \"Unauthorized\"}"
Status: :error
Event ID: %Sentry.ClientError{
reason: :server_error,
http_response: {401, [...headers...], "{\"error\": \"Unauthorized\"}"}
}
-
✅ Tested BOTH DSN formats from BetterStack:
- Documentation page format:
https://[key]@s1592187.eu-nbg-2.betterstackdata.com/1 - Data ingestion page format:
https://[key]@eu-nbg-2.betterstackdata.com/1592187 - Both fail with identical 401 errors
- Documentation page format:
-
✅ Confirmed SDK is working correctly:
- Events are being constructed properly
- HTTP requests are being sent successfully
- Using official
Sentry.HackneyClient - Sentry SDK v11.0.4
-
✅ Followed official Sentry Elixir docs exactly:
- Minimal vanilla configuration
- Using documented capture methods
- No custom filters or before_send hooks active
- Standard error/message capture patterns
-
✅ Verified config loading:
- DSN is correctly loaded from environment
- All config values are present and correct
- Using
:syncsend mode to see immediate errors
-
Why are there two different DSN formats in different parts of the UI?
- Which format is correct for the Elixir Sentry SDK?
- Should we expect both formats to work?
-
Is there a setup step required in BetterStack UI before the Sentry endpoint accepts events?
- Do we need to enable the integration somewhere?
- Are there API keys or tokens needed beyond the DSN?
-
Are there known compatibility issues with:
- Sentry Elixir SDK v11.0.4?
- The
Sentry.HackneyClient?
-
Does the BetterStack Sentry endpoint require any additional authentication headers beyond what's embedded in the DSN?
- The Sentry SDK is successfully constructing and sending events
- The BetterStack server is responding (not a network/firewall issue)
- The 401 suggests authentication/authorization problem specifically
- Both message capture and exception capture fail identically
- Both DSN formats fail identically
- We're following the official Sentry Elixir documentation exactly
Expected: Events appear in BetterStack Errors dashboard Actual: HTTP 401 Unauthorized from BetterStack endpoint Tested: Both DSN formats from different BetterStack pages