Debugging Guide
Comprehensive guide for debugging LuaBeans - Community Manager issues.
Debug Mode
Enable debug mode in development:
NODE_ENV=developmentThis will:
Show detailed error messages
Enable verbose logging
Disable production optimizations
Logging
Application Logs
Application logs are output to the console (stdout/stderr). In production, redirect these to log files:
node src/server.js >> /var/log/luabeans/app.log 2>&1Log Levels
Info: Normal operation messages
Warn: Warning messages (non-critical issues)
Error: Error messages (critical issues)
Common Log Messages
Startup:
Database Connection:
Discord Bot:
Database Debugging
Check Database Connection
View Table Structure
Check Table Exists
View Data
Check Indexes
View Foreign Key Constraints
Common Database Issues
Connection Refused:
Check MySQL is running:
sudo systemctl status mysqlVerify credentials in
.envCheck firewall rules
Table Doesn't Exist:
Run schema:
mysql -u user -p database < db/schema.sqlOr let Sequelize auto-create on boot
Foreign Key Constraint Violations:
Check referenced records exist
Verify constraint definitions in schema
Discord Debugging
OAuth2 Issues
Error: Invalid Redirect URI
Verify
DISCORD_CALLBACK_URLmatches exactly in Discord Developer PortalCheck for trailing slashes
Verify protocol (http vs https)
Error: Not in Guild
Verify
DISCORD_GUILD_IDis correctCheck user is actually in the Discord server
Verify bot has permissions to read members
Error: OAuth2 Application Not Found
Verify
DISCORD_CLIENT_IDandDISCORD_CLIENT_SECRETare correctCheck Discord application still exists
Verify application hasn't been deleted
Bot Issues
Bot Not Responding:
Check bot is running:
npm run botVerify
DISCORD_BOT_TOKENis correctCheck bot has required intents:
Guilds
Guild Members
Guild Messages
Message Content
Commands Not Appearing:
Wait 1 hour for global commands to propagate
Or set
DISCORD_BOT_PUBLIC_COMMANDS=falsefor instant guild commandsRedeploy commands:
npm run bot:deploy
Rate Limiting:
Check logs for rate limit warnings
Bot automatically handles rate limits with retries
Consider reducing command frequency
Discord API Testing
Test Discord API manually:
Session Debugging
Check Session Store
Clear All Sessions
Session Issues
Sessions Not Persisting:
Verify session table exists
Check
SESSION_SECRETis setVerify database connection
Session Expired Too Quickly:
Check session expiration settings (default: 7 days)
Verify server time is correct (NTP sync)
CSRF Token Errors:
Clear browser cookies
Check
TRUST_PROXYis set correctly if behind proxyVerify session is working
Permission Debugging
Check User Permissions
Check Department Access
Permission Cache
Permissions are cached. To refresh:
User: Dashboard → "Refresh roles" button
Admin: Admin → "Refresh roles for all users" (background job)
FiveM Integration Debugging
API Token Issues
Error: Invalid Token
Verify
LEO_API_TOKENmatches between web panel and FiveM resourceCheck token is sent in Authorization header:
Bearer <token>Verify token hasn't expired or been changed
Error: Unauthorized
Check API endpoint is protected with
LEO_API_TOKENVerify token format is correct
Check request includes Authorization header
FiveM Resource Issues
Resource Not Starting:
Check convars are set correctly:
Verify API endpoint is accessible from FiveM server
Check resource console for errors
API Calls Failing:
Test API endpoint manually:
Check FiveM server can reach your web panel
Verify SSL certificate is valid (if using HTTPS)
Discord Identifier Issues
Error: No Discord Identifier
Verify player has
discord:identifier in FiveMCheck player identifiers:
GetPlayerIdentifiers(source)Ensure Discord identifier is in format:
discord:123456789012345678
File Upload Debugging
Upload Directory Issues
Error: Cannot Write to Upload Directory
Check
UPLOAD_DIRexists:ls -la ./uploadsVerify write permissions:
chmod 755 ./uploadsCheck disk space:
df -h
Error: File Too Large
Check
MAX_FILE_SIZEin.env(default: 100MB)Verify proxy allows upload size (Nginx:
client_max_body_size)Check Cloudflare upload limits
Upload Processing Issues
Uploads Not Saving:
Check file system permissions
Verify
UPLOAD_DIRpath is correct (absolute vs relative)Check disk space availability
Performance Debugging
Slow Queries
Enable query logging in MySQL:
View slow queries:
Memory Issues
Monitor Node.js memory:
Database Connection Pool
Check active connections:
Network Debugging
Check Port Availability
Test HTTP Endpoints
Proxy Issues
Error: Trust Proxy Not Working
Set
TRUST_PROXY=truein.envVerify proxy sends
X-Forwarded-ProtoheaderCheck
X-Forwarded-Forheader format
Error: HTTPS Redirect Loop
Verify
TRUST_PROXY=trueis setCheck proxy sends
X-Forwarded-Proto: httpsVerify
FORCE_HTTPS=trueonly in production
Common Error Messages
Database Errors
Error: Connection refused
MySQL is not running
Wrong host/port
Firewall blocking connection
Error: Access denied
Wrong username/password
User doesn't have permissions
Error: Unknown database
Database doesn't exist
Wrong database name in
.env
Discord Errors
Error: Invalid OAuth2 redirect_uri
Callback URL mismatch
URL not registered in Discord portal
Error: Invalid client secret
Wrong client secret
Application deleted or regenerated
Error: Missing Permissions
Bot doesn't have required permissions
Bot not in server
Application Errors
Error: EBADCSRFTOKEN
CSRF token mismatch
Session expired
Cookie issues
Error: EADDRINUSE
Port already in use
Another instance running
Debug Tools
Health Endpoints
/healthz- Always 200 (process alive)/readyz- 200 only if database connected/metrics- Performance metrics (if enabled)
Admin Diagnostics
Navigate to /admin/diagnostics for:
System health check
Database connection status
Discord connection status
Configuration validation
Getting Help
If you're still experiencing issues:
Check Common Issues
Review Error Messages
Check application logs
Review database logs
Test with minimal configuration
Contact support with:
Error message
Relevant log excerpts
Configuration (sanitized)
Steps to reproduce
Last updated
