Troubleshooting Guide¶
This guide helps diagnose and resolve common issues with the AzharStore Medusa backend.
Table of Contents¶
- Docker Issues
- Database Issues
- Redis Issues
- Backend Issues
- Frontend Issues
- API Issues
- Migration Issues
- Performance Issues
- Security Issues
Docker Issues¶
Docker Compose Won't Start¶
Symptoms:
- docker compose up fails
- Services exit immediately
- Port binding errors
Solutions:
-
Check Docker is running:
-
Check for port conflicts:
-
Stop conflicting services or change ports in
docker-compose.yml -
Check Docker logs:
-
Rebuild containers:
Container Keeps Restarting¶
Symptoms:
- Container status shows Restarting
- Logs show startup errors
Solutions:
-
View container logs:
-
Check environment variables:
-
Enter container to debug:
-
Check resource limits:
Volume Mount Issues¶
Symptoms: - Data not persisting - Permission errors - Volume not found
Solutions:
-
List volumes:
-
Inspect volume:
-
Recreate volume:
Database Issues¶
Cannot Connect to PostgreSQL¶
Symptoms: - Connection refused errors - Timeout errors - Authentication errors
Solutions:
-
Check PostgreSQL is running:
-
Check DATABASE_URL in
.env: -
Test connection:
-
Check PostgreSQL logs:
-
Verify credentials:
Migration Failures¶
Symptoms: - Migration script fails - Tables not created - Schema mismatch
Solutions:
-
Check migration status:
-
Revert migrations:
-
Re-run migrations:
-
Check for locked migrations:
-
Manually unlock:
Database Performance Issues¶
Symptoms: - Slow queries - High CPU usage - Connection timeouts
Solutions:
-
Check active queries:
-
Kill long-running queries:
-
Vacuum database:
-
Rebuild indexes:
-
Check table sizes:
Redis Issues¶
Cannot Connect to Redis¶
Symptoms: - Connection refused - Timeout errors - Event bus not working
Solutions:
-
Check Redis is running:
-
Check REDIS_URL in
.env: -
Test connection:
-
Check Redis logs:
Redis Memory Issues¶
Symptoms: - Out of memory errors - Keys being evicted - Slow performance
Solutions:
-
Check memory usage:
-
Check key count:
-
Clear cache (if safe):
-
Adjust maxmemory in
docker-compose.yml:
Backend Issues¶
Backend Won't Start¶
Symptoms: - Container exits immediately - Port 9000 not accessible - Build errors
Solutions:
-
Check backend logs:
-
Check environment variables:
-
Verify dependencies installed:
-
Rebuild backend:
Module Not Loading¶
Symptoms: - Module service not found - Route returns 404 - Module not registered
Solutions:
-
Check module registration in
medusa-config.ts: -
Check module files exist:
-
Check for TypeScript errors:
-
Restart backend:
Workflow Fails¶
Symptoms: - Order creation fails - Workflow steps error - Compensation not running
Solutions:
-
Check workflow logs:
-
Check workflow definition:
-
Verify all steps are defined:
-
Check for missing dependencies:
Frontend Issues¶
Frontend Won't Load¶
Symptoms: - Blank page - 404 errors - Build failures
Solutions:
-
Check store logs:
-
Check Nginx configuration:
-
Check API base URL:
-
Rebuild frontend:
API Calls Failing¶
Symptoms: - CORS errors - Network errors - 401/403 errors
Solutions:
-
Check CORS configuration:
-
Check backend is accessible:
-
Check browser console for errors
- Verify API base URL in
frontend/store/src/services/api.js - Check authentication token:
API Issues¶
404 Not Found¶
Symptoms: - API endpoint returns 404 - Route not registered
Solutions:
-
Verify route file exists:
-
Check route is exported:
-
Restart backend:
-
Check URL path:
500 Internal Server Error¶
Symptoms: - API returns 500 - Unhandled exceptions
Solutions:
-
Check backend logs:
-
Check for TypeScript errors:
-
Verify service methods exist:
-
Check database connection:
Authentication Errors¶
Symptoms: - 401 Unauthorized - Token invalid - Session expired
Solutions:
-
Check JWT secret:
-
Verify token format:
-
Check admin session:
-
Clear local storage and cookies:
Migration Issues¶
Migration Script Fails¶
Symptoms: - Script exits with error - Data not migrated - Connection errors
Solutions:
-
Check Supabase credentials:
-
Test Supabase connection:
-
Check script logs:
-
Verify Supabase tables exist:
Verification Fails¶
Symptoms: - Count mismatch - Data integrity errors - Sample check failures
Solutions:
-
Re-run migration:
-
Check for duplicates:
-
Remove duplicates:
-
Re-run verification:
Performance Issues¶
Slow API Responses¶
Symptoms: - API calls take > 1 second - Frontend loading slowly - Database queries slow
Solutions:
-
Check backend response time:
-
Check database query performance:
-
Add database indexes:
-
Enable Redis caching:
High Memory Usage¶
Symptoms: - Container OOM killed - System slow - Memory leaks
Solutions:
-
Check container memory:
-
Check Node.js memory:
-
Increase memory limit in
docker-compose.yml: -
Check for memory leaks:
Security Issues¶
Environment Variables Exposed¶
Symptoms: - Secrets in logs - .env committed to git - Secrets in error messages
Solutions:
-
Check .env is in .gitignore:
-
Remove from git history:
-
Regenerate exposed secrets:
-
Update .env with new secrets
CORS Errors¶
Symptoms: - Browser CORS errors - API blocked - Mixed content errors
Solutions:
-
Check CORS configuration:
-
Add frontend URL to CORS:
-
Restart backend:
-
Use HTTPS in production to avoid mixed content
Getting Help¶
Collect Diagnostic Information¶
-
System info:
-
Service status:
-
Recent logs:
-
Environment variables:
-
Database status:
Where to Look for Help¶
- Documentation: Check
docs/directory - MedusaJS Documentation: https://docs.medusajs.com
- GitHub Issues: Search existing issues or create new one
- Community Forums: MedusaJS Discord or community channels
Creating a Bug Report¶
Include:
- Description: What happened
- Steps to reproduce: How to trigger the issue
- Expected behavior: What should happen
- Actual behavior: What actually happened
- Environment: OS, Docker version, Node version
- Logs: Relevant error logs
- Logs: Diagnostic information from above
Common Error Messages¶
"Cannot find module '@medusajs/framework'"¶
Cause: Dependencies not installed
Solution:
"Connection refused"¶
Cause: Service not running or wrong port
Solution: Check service is running and port is correct
"Migration already applied"¶
Cause: Migration already run
Solution: This is normal, no action needed
"Out of memory"¶
Cause: Container memory limit exceeded
Solution: Increase memory limit or optimize code
"ECONNREFUSED"¶
Cause: Network connection issue
Solution: Check network connectivity and service status