| name | langfuse-common-errors |
| description | Diagnose and fix common Langfuse errors and exceptions.
Use when encountering Langfuse errors, debugging missing traces,
or troubleshooting integration issues.
Trigger with phrases like "langfuse error", "fix langfuse",
"langfuse not working", "debug langfuse", "traces not appearing".
|
| allowed-tools | Read, Grep, Bash(curl:*) |
| version | 1.0.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
Langfuse Common Errors
Overview
Quick reference for the top 10 most common Langfuse errors and their solutions.
Prerequisites
- Langfuse SDK installed
- API credentials configured
- Access to error logs
Instructions
Step 1: Identify the Error
Check error message and code in your logs or console.
Step 2: Find Matching Error Below
Match your error to one of the documented cases.
Step 3: Apply Solution
Follow the solution steps for your specific error.
Output
- Identified error cause
- Applied fix
- Verified resolution
Error Handling
1. Authentication Failed
Error Message:
Langfuse: Unauthorized - Invalid API key
Error: 401 Unauthorized
Cause: API key is missing, expired, or mismatched with host.
Solution:
echo "Public: $LANGFUSE_PUBLIC_KEY"
echo "Secret: ${LANGFUSE_SECRET_KEY:0:10}..."
echo "Host: $LANGFUSE_HOST"
curl -X GET "$LANGFUSE_HOST/api/public/health" \
-H "Authorization: Basic $(echo -n "$LANGFUSE_PUBLIC_KEY:$LANGFUSE_SECRET_KEY" | base64)"
2. Traces Not Appearing in Dashboard
Symptom: Code runs without errors but traces don't show up.
Cause: Data not flushed before process exits.
Solution:
await langfuse.flushAsync();
await langfuse.shutdownAsync();
process.on("beforeExit", async () => {
await langfuse.shutdownAsync();
});
3. Network/Connection Errors
Error Message:
FetchError: request to https://cloud.langfuse.com failed
ECONNREFUSED / ETIMEDOUT
Cause: Network connectivity or firewall issues.
Solution:
curl -v https://cloud.langfuse.com/api/public/health
nslookup cloud.langfuse.com
curl -v $LANGFUSE_HOST/api/public/health
const langfuse = new Langfuse({
requestTimeout: 30000,
});
4. Missing Token Usage
Symptom: Generations appear but token counts are 0.
Cause: Usage data not captured from LLM response.
Solution:
const stream = await openai.chat.completions.create({
model: "gpt-4",
messages,
stream: true,
stream_options: { include_usage: true },
});
generation.end({
output: content,
usage: {
promptTokens: response.usage?.prompt_tokens || 0,
completionTokens: response.usage?.completion_tokens || 0,
},
});
5. Trace/Span Not Ending
Symptom: Traces show as "in progress" indefinitely.
Cause: Missing .end() call on spans/generations.
Solution:
const span = trace.span({ name: "operation" });
try {
const result = await doWork();
span.end({ output: result });
return result;
} catch (error) {
span.end({ level: "ERROR", statusMessage: String(error) });
throw error;
}
const span = trace.span({ name: "operation" });
try {
return await doWork();
} finally {
span.end();
}
6. Duplicate Traces
Symptom: Same operation creates multiple traces.
Cause: Client instantiated multiple times or missing singleton.
Solution:
let langfuseInstance: Langfuse | null = null;
export function getLangfuse(): Langfuse {
if (!langfuseInstance) {
langfuseInstance = new Langfuse();
}
return langfuseInstance;
}
7. SDK Version Mismatch
Error Message:
TypeError: langfuse.trace is not a function
Property 'observeOpenAI' does not exist
Cause: Outdated SDK or breaking API change.
Solution:
npm list langfuse
npm install langfuse@latest
8. Environment Variable Not Loaded
Error Message:
Langfuse: Missing required configuration - publicKey
Cause: .env file not loaded or wrong variable names.
Solution:
cat .env | grep LANGFUSE
import "dotenv/config";
import { config } from "dotenv";
config({ path: ".env.local" });
9. Self-Hosted Connection Issues
Error Message:
Failed to connect to localhost:3000
Certificate verification failed
Cause: Self-hosted instance not running or SSL issues.
Solution:
docker ps | grep langfuse
curl http://localhost:3000/api/public/health
export NODE_TLS_REJECT_UNAUTHORIZED=0
const langfuse = new Langfuse({
baseUrl: "http://localhost:3000",
});
10. Rate Limiting
Error Message:
Error: 429 Too Many Requests
Retry-After: 60
Cause: Exceeded Langfuse API rate limits.
Solution:
const langfuse = new Langfuse({
flushAt: 50,
flushInterval: 30000,
});
Quick Diagnostic Commands
curl -s https://status.langfuse.com
curl -I https://cloud.langfuse.com/api/public/health
env | grep LANGFUSE
curl -X GET "https://cloud.langfuse.com/api/public/traces" \
-H "Authorization: Basic $(echo -n "$LANGFUSE_PUBLIC_KEY:$LANGFUSE_SECRET_KEY" | base64)" \
| head -c 200
Escalation Path
- Collect evidence with
langfuse-debug-bundle
- Check Langfuse Status
- Search GitHub Issues
- Join Discord Community
- Contact support with debug bundle
Resources
Next Steps
For comprehensive debugging, see langfuse-debug-bundle.