local
Sentry for local development
Commands
Section titled “Commands”sentry local serve
Section titled “sentry local serve”Start the local dev server and tail events
Options:
| Option | Description |
|---|---|
-p, --port <port> | Port to listen on (default 8969) (default: "8969") |
-H, --host <host> | Hostname to bind to (default localhost) (default: "localhost") |
-q, --quiet | Suppress per-envelope tail output |
-f, --filter <filter>... | Only show items of this type (repeatable: error, transaction, log, ai) |
-F, --format <format> | Output format: human (default) or json (NDJSON) (default: "human") |
sentry local run <command...>
Section titled “sentry local run <command...>”Run a command with the local dev server enabled
Arguments:
| Argument | Description |
|---|---|
<command...> | Command to run |
Options:
| Option | Description |
|---|---|
-p, --port <port> | Port for the local server (default 8969) (default: "8969") |
--host <host> | Hostname for the local server (default localhost) (default: "localhost") |
All commands support --json for machine-readable output and --fields to select specific JSON fields.
sentry local runs a local development server that captures Sentry SDK envelopes from your dev stack and surfaces errors, traces, and logs in real time — right in your terminal. No authentication required.
No DSN is required either. If your app has no DSN configured, events flow only to the local server — nothing reaches your Sentry organization and no production quota is used. If a DSN is set, the SDK sends to both Sentry and the local server.
If a server is already running on the port, the command attaches as an SSE consumer instead of starting a duplicate.
Examples
Section titled “Examples”# Start the server and tail events (default)sentry local
# Run your app with the local server auto-enabledsentry local run -- npm run devsentry local run -- python manage.py runserver
# Use a custom portsentry local --port 9000
# Only show errors and logs (filter out transactions)sentry local -f error -f log
# Run quietly (suppress per-envelope tail output)sentry local --quietsentry local run
Section titled “sentry local run”Runs a command with SENTRY_SPOTLIGHT injected into the environment. The Sentry SDK automatically detects this variable and sends envelopes to the local server. No code changes needed.
Env vars injected into the child process:
| Variable | Value |
|---|---|
SENTRY_SPOTLIGHT | http://localhost:<port>/stream |
<PREFIX>SENTRY_SPOTLIGHT | http://localhost:<port>/stream |
SENTRY_TRACES_SAMPLE_RATE | 1 (unless already set) |
The <PREFIX> variants cover every common framework client prefix so the spotlight URL is inlined into your browser bundle no matter which bundler you use: PUBLIC_ (SvelteKit, Astro, Qwik), NEXT_PUBLIC_ (Next.js), VITE_ (Vite), NUXT_PUBLIC_ (Nuxt), REACT_APP_ (Create React App), VUE_APP_ (Vue CLI), and GATSBY_ (Gatsby).
Server vs. client. Server-side SDKs (@sentry/node, Python, and friends) read SENTRY_SPOTLIGHT automatically — no code changes needed.
For browser/client events, the CLI exposes the spotlight URL under every framework client prefix above. Once the browser SDK reads these variables automatically, client-side capture will be zero-config too. Until then, reference the variable matching your framework in your client config:
// Next.js example — other frameworks use their own env access pattern// (e.g. import.meta.env.VITE_SENTRY_SPOTLIGHT for Vite-based frameworks).Sentry.init({ spotlight: process.env.NEXT_PUBLIC_SENTRY_SPOTLIGHT ?? false });Endpoints
Section titled “Endpoints”| Method | Path | Description |
|---|---|---|
POST | /stream | Envelope ingest |
POST | /api/{projectId}/envelope/ | Sentry SDK ingest path |
GET | /stream | Server-Sent Events feed of incoming envelopes |
GET | /health | Liveness check (returns OK) |
Tail output
Section titled “Tail output”By default, incoming envelopes are pretty-printed to the terminal:
14:32:01 [ERROR] [SERVER] TypeError: x is not a function [app.ts:42:5] [handleRequest]14:32:02 [TRACE] [BROWSER] [http.client] GET /api/users [245ms] [3 spans]14:32:03 [INFO] [SERVER] User logged in [user_id=1234] [region=us]Errors show the exception type, message, and top stack frame. Transactions show the operation, duration, and span count. Logs show the severity level, message, and custom attributes.
Use --filter / -f to narrow the output to specific event types (repeatable):
sentry local -f error -f log # only errors and logsUse --quiet to suppress tail output entirely if you only need the SSE stream.
Agent monitoring
Section titled “Agent monitoring”sentry local shows rich output for AI agent spans when your SDK instruments with OpenTelemetry semantic attributes:
14:32:01 [TRACE] [SERVER] [gen_ai] chat anthropic/claude-4-sonnet [1200ms] [5 spans]14:32:02 [TRACE] [SERVER] [mcp] tools/call search_files [320ms]14:32:03 [TRACE] [SERVER] [db] SELECT users [postgresql] [12ms]14:32:04 [ERROR] [SERVER] RateLimitError: API quota exceeded [api_client.py:42]GenAI operations show the model name, MCP tool calls show the tool being invoked, and database queries show the system and query summary. This works automatically when your Sentry SDK is configured with AI/LLM integrations.
To watch only agent activity, filter to the ai item type:
sentry local -f ai # only AI/agent spanssentry local -f ai -f error # agent spans and errorsJSON output
Section titled “JSON output”Use --format json (or -F json) for machine-readable NDJSON output, one JSON object per envelope item:
sentry local --format json{"type":"transaction","timestamp":1700000001,"op":"gen_ai","label":"chat anthropic/claude-4-sonnet","duration_ms":1200,"span_count":5,"source":"server"}{"type":"error","timestamp":1700000002,"error_type":"RateLimitError","message":"API quota exceeded","source":"server"}{"type":"log","timestamp":1700000003,"level":"info","message":"User logged in","attributes":{"user_id":1234},"source":"server"}This is useful for AI coding agents and automation tools that need to consume Sentry events programmatically.