Troubleshooting
Common issues, solutions, and debugging tips for the DashClicks microservices architecture.
Quick Diagnostics
Service Health Check
Verify core services are running and healthy:
# Check API Router (main gateway)
curl http://localhost:5001/status
# Check Internal API
curl http://localhost:5002/status
# Check External Integrations API
curl http://localhost:5003/status
# Check Dashboard Gateway
curl http://localhost:5000/status
# Check Socket Services
curl http://localhost:6001/status # Conversation Socket
curl http://localhost:4000/status # General Socket
Expected Response:
{
"status": "ok"
}
Problem Indicators:
- No response - Service isn't running
- Error response - Service has configuration or database issues
- Connection refused - Port not available or service crashed
Installation & Setup Issues
Initial Setup Problems
Error:
pnpm run build fails with missing dependencies
Solutions:
-
Check .env file exists:
ls -la .env -
Copy from sample template:
cp .env.sample .env -
Ask fellow developers for missing values:
- Contact team members for actual MongoDB connection strings
- Request JWT secrets and API keys for development environment
- Get third-party integration credentials (Stripe, Twilio, etc.)
-
Verify file contents:
cat .env
# Should show your MongoDB URL, JWT secrets, and API keys -
Test environment loading:
node -e "require('dotenv').config(); console.log(process.env.MONGO_DB_URL ? 'Environment loaded' : 'Environment not loaded')"
Import/Module Errors
Error:
Cannot find module './services/something'
Causes & Solutions:
-
Use CommonJS require without .js extension:
// ✅ Correct for DashClicks
const { Service } = require('./services/myService');
const userModel = require('./models/user');
const authUtils = require('./utilities/auth'); -
Check shared files are copied:
# Verify models and utilities exist in services
ls -la internal/api/v1/models/
ls -la external/Integrations/utilities/
ls -la conversation-socket/models/ -
Common folder files not copied:
# Check if conversation files were copied from common/
ls -la internal/api/v1/conversation-v2/services/
ls -la internal/api/v1/conversation-v2/constants/
ls -la conversation-socket/src/services/
ls -la conversation-socket/src/constants/ -
Run copySharedFiles for all shared content:
# This copies from both /shared and /common folders
pnpm run copySharedFiles -
Edit files in correct locations:
- Models/Utilities: Edit in
/shared/folder only - Conversation services: Edit in
/common/conversations/folder only - Never edit copied files in service folders - they are Git-ignored
- Models/Utilities: Edit in
-
Node.js version compatibility:
node --version # Should be 18+
Port Already in Use
Error:
Error: listen EADDRINUSE: address already in use :::5001
Solutions:
-
Find what's using the port:
lsof -i :5001
# or
netstat -tulpn | grep :5001 -
Kill the process:
kill -9 <PID> -
Check if another DashClicks service is running:
# Check all DashClicks service ports
lsof -i :5000 -i :5001 -i :5002 -i :5003 -i :4000 -i :6001 -i :6002 -i :5008 -
Stop all services and restart through VS Code debugger
Runtime Issues
Database Connection Problems
Error:
MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
Solutions:
-
Check MongoDB connection string:
# Verify MongoDB URL in .env
echo $MONGO_DB_URL -
Test MongoDB connectivity:
# Using MongoDB shell
mongosh "your_mongodb_connection_string" -
Check network access:
- Ensure MongoDB Atlas IP whitelist includes your IP
- Verify firewall settings allow MongoDB traffic
-
Restart services with fresh connection:
- Stop all services in VS Code debugger
- Restart "Start All Services" configuration
Shared Files Out of Sync
Error:
Cannot find module './models/user' or './utilities/auth'
Solutions:
-
Copy shared files:
pnpm run copySharedFiles -
Verify shared files were copied:
# Check if models exist in service folders
ls -la internal/api/v1/models/
ls -la external/Integrations/models/ -
Check for Git issues:
# These folders should be Git-ignored
git status | grep models/
git status | grep utilities/
Third-Party API Issues
Error:
Stripe API Error: 401 Unauthorized
Solutions:
-
Verify API keys in .env:
# Check Stripe keys (test vs live)
echo $STRIPE_SECRET_KEY | head -c 20 -
Test API connectivity:
# Test Stripe API directly
curl -H "Authorization: Bearer $STRIPE_SECRET_KEY" \
https://api.stripe.com/v1/customers/limit=1 -
Check webhook endpoints:
- Ensure ngrok is running for local development
- Verify webhook URLs in third-party dashboards
-
Review integration logs:
- Check External API service logs in VS Code debugger console
Service Communication Issues
Service Not Responding
Symptoms:
- Services can't communicate with each other
- API Router returns 503 Service Unavailable
- Socket connections failing
Solutions:
-
Check service startup order:
- Always start API Router (5001) first
- Then start Internal API (5002) and External API (5003)
- Start socket services after core APIs
-
Verify service URLs in .env:
# Check service communication URLs
echo $INTERNAL_BASE_URL
echo $EXTERNAL_BASE_URL
echo $SOCKET_API
echo $CONVERSATION_SOCKET -
Test inter-service connectivity:
# From API Router to Internal API
curl http://localhost:5002/status
# From API Router to External API
curl http://localhost:5003/status
Queue Manager Issues
Error:
Queue processing failed - Redis connection error
Solutions:
-
Check Redis connection:
# Test Redis connectivity
redis-cli ping -
Verify Redis configuration:
echo $REDIS_HOST
echo $REDIS_PORT -
Check queue flags:
- Set queue flags to
falsein development to prevent background processing - Enable only necessary queues for testing
- Set queue flags to
Socket Connection Problems
Symptoms:
- Real-time features not working
- Chat messages not delivering
- Live updates not appearing
Solutions:
-
Check socket services are running:
curl http://localhost:4000/status # General Socket
curl http://localhost:6001/status # Conversation Socket -
Verify Redis for socket scaling:
- Socket services require Redis for multi-instance communication
- Check Redis connection in socket service logs
-
Test socket endpoints:
- Use browser developer tools to check WebSocket connections
- Look for CORS issues in network tab
Performance Issues
Memory Problems
Error:
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
Solutions:
-
Increase Node.js memory:
export NODE_OPTIONS="--max-old-space-size=2048"
pnpm start -
Process documents in batches:
- Move some documents temporarily
- Process in smaller groups
- Monitor memory usage
-
Check for memory leaks:
# Monitor memory over time
while true; do ps aux | grep node | grep -v grep; sleep 5; done
High CPU Usage
Symptoms:
- CPU constantly at 100%
- System becomes unresponsive
Solutions:
-
Limit concurrent processing:
- Reduce batch sizes in document processing
- Add delays between operations
-
Check for infinite loops:
- Review logs for repeated errors
- Restart API if needed
-
Profile the application:
node --prof apps/api/src/index.ts
Network & Connectivity Issues
CORS Errors
Error in Browser:
Access to fetch at 'http://localhost:5001/v1/users' from origin 'http://localhost:3000' has been blocked by CORS policy
Solution: DashClicks services have CORS enabled by default. If you see this error:
-
Verify API Router is running:
curl http://localhost:5001/status -
Check Dashboard Gateway proxy:
- Ensure Dashboard Gateway (port 5000) is properly proxying requests
- Verify frontend is making requests through Dashboard Gateway
-
Check service-specific CORS:
- Review CORS settings in individual services
- Ensure proper headers are set for OPTIONS requests
Service Unreachable
Error:
curl: (7) Failed to connect to localhost port 5001: Connection refused
Solutions:
-
Verify services are running:
# Check all DashClicks services
ps aux | grep -E "node.*internal|node.*router|node.*dashboard" -
Check VS Code debugger:
- Use VS Code Debug panel to start services
- Check debug console for startup errors
-
Test individual services:
curl http://localhost:5001/status # API Router
curl http://localhost:5002/status # Internal API
curl http://localhost:5003/status # External API
Development Issues
Auto-restart Not Working
Problem: Changes to code don't trigger service restart in VS Code debugger
Solutions:
-
Check VS Code debugger auto-restart:
- Ensure debug configuration has
"restart": true - Verify file watching is enabled in debug console
- Ensure debug configuration has
-
Manual service restart:
- Stop debug session in VS Code
- Start fresh debug session for affected service
-
Check file permissions:
chmod -R 755 internal/api/v1/
chmod -R 755 external/
Module Resolution Errors
Error:
Cannot find module '../models/user.js'
Solutions:
-
Check shared files were copied:
# Verify models exist in service
ls -la internal/api/v1/models/user.js
ls -la external/Integrations/models/user.js -
Run shared file copy:
npm run copySharedFiles
# or for development with symlinks
npm run dev:build -
Check require/import paths:
- Ensure correct relative paths to copied shared files
- Verify no circular dependencies between services
VS Code Debugger Issues
Services Won't Start in Debugger
Problem: VS Code debug configurations fail to launch services
Solutions:
-
Check launch.json configuration:
# Verify .vscode/launch.json exists
ls -la .vscode/launch.json -
Verify Node.js path:
- Ensure Node.js 18+ is installed and in PATH
- Check VS Code is using correct Node.js version
-
Clear VS Code cache:
- Close VS Code completely
- Delete
.vscode/.debugfolder if exists - Reopen VS Code and try again
-
Check environment variables:
- Ensure .env file is in root directory
- Verify no syntax errors in .env file
Breakpoints Not Working
Problem: Debugger doesn't pause at breakpoints
Solutions:
-
Check source maps:
- Ensure services are running in development mode
- Verify
NODE_ENV=developmentin debug configuration
-
Restart debugger:
- Stop all running debug sessions
- Start fresh debug session for specific service
-
Check file paths:
- Ensure breakpoints are set in actual source files
- Not in copied or generated files
Debugging Tips
Enable Debug Logging
Add more detailed logging to understand what's happening:
# In your .env file
DEBUG_MODE=true
NODE_ENV=development
LOG_LEVEL=debug
Service Health Check Script
Test all services systematically:
#!/bin/bash
# Create a debug script for DashClicks
echo "=== DashClicks Backend Debug Information ==="
echo "Date: $(date)"
echo ""
echo "=== Environment ==="
echo "Node version: $(node --version)"
echo "npm version: $(npm --version)"
echo "pnpm version: $(pnpm --version)"
echo ""
echo "=== Process Status ==="
ps aux | grep -E "node.*internal|node.*external|node.*router|node.*dashboard|node.*socket|node.*queue|node.*notification" | grep -v grep
echo ""
echo "=== Port Status ==="
echo "Checking DashClicks service ports..."
for port in 5000 5001 5002 5003 4000 6001 6002 5008; do
if lsof -i :$port > /dev/null 2>&1; then
echo "Port $port: IN USE"
else
echo "Port $port: FREE"
fi
done
echo ""
echo "=== Service Health Checks ==="
for port in 5001 5002 5003; do
if curl -s http://localhost:$port/status > /dev/null 2>&1; then
echo "Service on port $port: HEALTHY"
else
echo "Service on port $port: NOT RESPONDING"
fi
done
echo ""
echo "=== Database Connection ==="
if [[ -n "$MONGO_DB_URL" ]]; then
echo "MongoDB URL configured: YES"
else
echo "MongoDB URL configured: NO"
fi
echo "=== Shared Files Status ==="
if [[ -d "shared/models" && -d "shared/utilities" ]]; then
echo "Shared folders exist: YES"
echo "Models count: $(find shared/models -name "*.js" | wc -l)"
echo "Utilities count: $(find shared/utilities -name "*.js" | wc -l)"
else
echo "Shared folders exist: NO"
fi
API Response Testing
Test API responses systematically:
# Test API Router
curl http://localhost:5001/status
# Test Internal API
curl http://localhost:5002/status
# Test External API
curl http://localhost:5003/status
# Test with verbose output for debugging
curl -v http://localhost:5001/status
Getting Further Help
Before Seeking Help
- Check this troubleshooting guide for your specific issue
- Review the logs for error messages and context
- Test with minimal configuration to isolate the problem
- Verify your environment meets the requirements
Information to Include
When reporting issues, include:
- Error messages (complete stack traces)
- Environment details (OS, Node.js version, package versions)
- Configuration (.env contents without API keys)
- Steps to reproduce the issue
- Expected vs actual behavior
Resources
- Configuration Guide - Environment setup
- Architecture Documentation - System understanding
- API Reference - Endpoint details
- Integration Examples - Working code samples
Most issues can be resolved by checking configuration, file permissions, and API key validity. The system is designed to be robust and self-healing, so many problems resolve automatically once the underlying cause is addressed.