Troubleshooting Mergen
Common issues and solutions for Mergen installation and operation.
๐จ Quick Fixes
Most Common Issues
| Problem | Quick Fix |
|---|---|
| "Command not found: mergen-server" | Use npx mergen-server |
| Port 3000 in use | Server tries 3000-3010 automatically |
| Extension not working | Restart browser after installing |
| IDE not showing tools | Restart IDE after setup |
| Server won't start | Run cd server && npm install && npm run build |
๐ฆ Installation Issues
"Command not found: mergen-server"
Cause: Package not installed globally or npx not working.
Solutions:
Use npx (recommended):
npx mergen-server@latest setupOr install globally:
npm install -g mergen-server mergen-server setupIf npx fails:
# Check npm installation npm --version # Update npm npm install -g npm@latest
"Port 3000 already in use"
Cause: Another service is using port 3000.
Solutions:
Let Mergen use another port (automatic):
- Mergen tries ports 3000-3010
- Check server output for actual port used
Kill process on port 3000:
# macOS/Linux lsof -ti:3000 | xargs kill -9 # Windows netstat -ano | findstr :3000 taskkill /PID <PID> /FFind what's using it:
# macOS/Linux lsof -i:3000 # Windows netstat -ano | findstr :3000
"npm ERR! EACCES: permission denied"
Cause: npm trying to install globally without permissions.
Solution (don't use sudo):
# Create npm global directory
mkdir ~/.npm-global
# Configure npm to use it
npm config set prefix '~/.npm-global'
# Add to PATH
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
# Now install
npm install -g mergen-server
"Node.js version too old"
Cause: Mergen requires Node.js 18.17+
Solution:
# Check current version
node --version
# If < 18.17, update from:
# https://nodejs.org/
# Or use nvm:
nvm install 20
nvm use 20
๐ฅ๏ธ Server Issues
Server won't start
Diagnostic steps:
Check Node.js version:
node --version # Must be >= 18.17Check if built:
ls server/dist/index.js # Should existCheck port availability:
lsof -i:3000 # Should be empty or show mergen
Solution:
# Full rebuild
cd server
npm install
npm run build
npm start
"Health check failed"
Diagnostic:
# Test health endpoint
curl http://127.0.0.1:3000/health
# Expected response:
# {"status":"ok","version":"1.0.0",...}
If it fails:
Check server is running:
ps aux | grep mergenCheck logs:
mergen-server start # Look for errors in outputTry different port:
# Server tries 3000-3010 automatically curl http://127.0.0.1:3001/health curl http://127.0.0.1:3002/health
Server crashes immediately
Check logs for errors:
mergen-server start 2>&1 | tee error.log
Common causes:
Missing dependencies:
cd server && npm installTypeScript not compiled:
cd server && npm run buildPermission issues:
# Check ~/.mergen/ permissions ls -la ~/.mergen/ chmod 755 ~/.mergen/
๐ Extension Issues
Extension not capturing events
Diagnostic steps:
Check extension is enabled:
- Open
chrome://extensions - Find "Mergen"
- Toggle should be ON (blue)
- Developer mode should be ON
- Open
Check server is running:
curl http://127.0.0.1:3000/healthCheck extension popup:
- Click Mergen icon in toolbar
- Should show "Connected" (green)
- Check port number matches server
Test with manual event:
// In browser DevTools console: console.error("Test error from Mergen")
Solutions:
Restart browser:
- Close ALL browser windows
- Reopen
- Check extension again
Reload extension:
- Go to
chrome://extensions - Find Mergen
- Click reload icon (circular arrow)
- Go to
Reinstall extension:
- Remove extension
- Restart browser
- Load unpacked again
Extension icon is gray (disconnected)
Cause: Extension can't reach server.
Solutions:
Start server:
mergen-server startCheck port in extension:
- Click gray icon
- Check port number
- Change if needed (3000-3010)
Check browser console:
- Right-click extension icon
- Inspect popup
- Look for errors in console
Extension popup says "Wrong port"
Solution:
- Click the port dropdown
- Try each port 3000-3010
- Or check server output:
mergen-server start # Look for: "HTTP ingest listening on http://127.0.0.1:XXXX"
๐ค IDE Integration Issues
The gate isn't blocking anything
General steps:
- Restart IDE (most common fix)
- Run validation:
mergen-server doctor - Check IDE-specific config below
Cursor Issues
Check configuration:
cat ~/.cursor/hooks.json
# Should have an afterFileEdit entry running `mergen-server gate-check --posthoc`
If missing, add manually:
mergen-server setup --ide=cursor
Restart Cursor after changes!
Verify:
- Edit a file to trigger a block-severity change (e.g. paste a fake secret)
- The bad content should be reverted right after it lands (detect-and-revert self-heal, not a pre-write block)
Claude Code Issues
Check configuration:
cat ~/.claude/settings.json
# Should have hooks.PreToolUse entries running `node ".../cli.js" gate-check`
If missing:
mergen-server setup --ide=claude-code
Test:
Ask Claude Code to run: terraform destroy -auto-approve. It should be blocked before it executes.
VS Code (Copilot, Cline, or any other extension) Issues
Requirements:
- The Mergen VS Code extension installed (Marketplace or Open VSX)
Plain VS Code has no AI-agent hook at the platform level, so coverage comes entirely from the Mergen extension's own document watcher (self-heal, same tier as Cursor).
If not working:
# Reinstall the extension
code --uninstall-extension OmerTahtaci.mergen
code --install-extension OmerTahtaci.mergen
# Restart VS Code
If you installed from Open VSX (Cursor, Windsurf, VSCodium) rather than the Microsoft
Marketplace, the extension is registered under mergen.mergen instead, so use that id in
the commands above. code --list-extensions | grep -i mergen shows which one you have.
Verify: edit 40+ characters in a file with a block-severity change. It should be reverted.
Windsurf Issues
Check configuration:
cat ~/.codeium/windsurf/hooks.json
# Should have pre_write_code / pre_run_command entries running mergen-server gate-check
If missing:
mergen-server setup --ide=windsurf
Verify: ask Windsurf's Cascade to edit a file with a block-severity change. It should be blocked before the write happens (true pre-write block, same tier as Claude Code).
โ๏ธ Common Error Messages
"TypeError: fetch is not defined"
Cause: Using Node.js < 18.0 (fetch not available)
Solution:
# Check version
node --version
# Update to Node 18.17+
# Download from: https://nodejs.org/
# Or use nvm
nvm install 20
nvm use 20
"Cannot find module '@modelcontextprotocol/sdk'"
Cause: Dependencies not installed
Solution:
cd server
rm -rf node_modules package-lock.json
npm install
npm run build
"ECONNREFUSED 127.0.0.1:3000"
Cause: Server not running
Solution:
# Start server
mergen-server start
# Or check if running
ps aux | grep mergen
curl http://127.0.0.1:3000/health
"EADDRINUSE: address already in use"
Cause: Port already taken
Solution:
Server should automatically try next port. If not:
# Kill existing process
lsof -ti:3000 | xargs kill -9
# Restart server
mergen-server start
๐ Performance Issues
High CPU usage
Diagnostic:
# Check CPU usage
top -pid $(pgrep -f mergen)
Causes:
- Too many events per second (>1000/sec)
- Large request/response bodies
- Circular references in objects
Solutions:
Check event rate:
# In browser console: console.count("test") # If counting very fast (>100/sec), that's the issueClear buffer:
curl -X DELETE http://127.0.0.1:3000/clearRestart server:
mergen-server restart
High memory usage
Cause: Buffer full of large events
Check:
# Monitor memory
top -pid $(pgrep -f mergen)
Normal:
- ~50-100 MB with empty buffer
- ~100-200 MB with full buffer (200 events)
If > 500 MB:
Clear buffer:
curl -X DELETE http://127.0.0.1:3000/clearRestart server:
mergen-server restart
๐งช Testing & Validation
Run full diagnostics
mergen-server test
This checks:
- โ Server binary exists
- โ Server starts successfully
- โ Health endpoint responds
- โ Event ingestion works
- โ IDE configuration correct
If any check fails, see specific section above.
Manual pipeline test
Complete end-to-end test:
# 1. Start server
mergen-server start &
SERVER_PID=$!
# 2. Wait for startup
sleep 2
# 3. Send test event
curl -X POST http://127.0.0.1:3000/ingest \
-H 'Content-Type: application/json' \
-d '{
"type": "console",
"level": "error",
"args": ["Pipeline test"],
"url": "http://test",
"timestamp": '$(date +%s000)'
}'
# 4. Verify event stored
curl -s http://127.0.0.1:3000/health | grep -q "Pipeline test" && echo "โ Working" || echo "โ Failed"
# 5. Clean up
kill $SERVER_PID
In your AI IDE, ask:
"Get recent logs"
Should see: "Pipeline test" error
๐ Advanced Debugging
Enable debug logging
# Set debug env var
DEBUG=mergen:* mergen-server start
# Or for verbose output
NODE_ENV=development mergen-server start
Check server logs
# Real-time logs
mergen-server start | tee mergen.log
# View logs
tail -f mergen.log
# Search for errors
grep -i error mergen.log
Inspect buffer state
# Get status
curl http://127.0.0.1:3000/health | jq
# Check buffer size
curl http://127.0.0.1:3000/health | jq '.bufferedEvents'
# Get recent events
curl http://127.0.0.1:3000/logs?limit=10 | jq
Browser DevTools inspection
Check extension is working:
- Open DevTools (F12)
- Go to Network tab
- Filter:
localhostor127.0.0.1 - Trigger console.log:
console.log("Test") - Should see: POST to
http://127.0.0.1:3000/ingest
Check request:
- Status should be 200
- Request payload should contain your log
๐ Still Stuck?
Before asking for help:
Run diagnostics:
mergen-server testCollect information:
# System info echo "OS: $(uname -s)" echo "Node: $(node --version)" echo "npm: $(npm --version)" # Check server curl http://127.0.0.1:3000/health # Check extension # Open chrome://extensions, screenshot Mergen card
Get help:
For bugs: Email omer@mergen.app.
Include:
- OS and version
- Node.js version
- Mergen version
- IDE and version
- Browser and version
- Steps to reproduce
- Error messages
- Output of
mergen-server test - Screenshots if applicable
Quick questions: Check FAQ.md first!