Troubleshooting Guide
Common issues and solutions for SelfHostedDB
This guide helps you resolve common problems when installing, deploying, or using SelfHostedDB.
Table of Contents
- Database Connection Issues
- Authentication Problems
- Application Won't Start
- Performance Issues
- Docker Issues
- Error Messages Reference
Database Connection Issues
Issue: "Cannot connect to PostgreSQL"
Symptoms:
- Error:
ECONNREFUSEDorConnection timeout - Application fails to start
- Health check fails
Solutions:
-
Verify PostgreSQL is running:
# Check if PostgreSQL is running docker ps | grep postgres # or pg_isready -h localhost -p 5432 -
Check connection string:
# Test connection manually psql "postgres://user:pass@host:5432/dbname" -
For Docker containers:
- Use
host.docker.internal(Windows/Mac) instead oflocalhost - Use
172.17.0.1(Linux) instead oflocalhost - Example:
postgres://user:pass@host.docker.internal:5432/dbname
- Use
-
Check firewall rules:
- Ensure port 5432 is open (if remote database)
- Verify security groups (AWS) or network rules (Azure/GCP)
-
Verify credentials:
- Check username and password are correct
- Ensure user has proper permissions
Related: See Installation Guide for connection string format
Issue: "SSL/TLS connection required"
Symptoms:
- Error:
SSL connection is required - Connection fails with cloud databases
Solutions:
-
Add SSL parameter to connection string:
postgres://user:pass@host:5432/dbname?sslmode=require -
For different SSL modes:
sslmode=require- Require SSL (recommended)sslmode=prefer- Prefer SSL, fallback to non-SSLsslmode=disable- Disable SSL (not recommended for production)
Related: See Security Guide for SSL configuration
Authentication Problems
Issue: "Invalid credentials" or "Unauthorized"
Symptoms:
- Can't login to application
- 401 Unauthorized errors
- Authentication fails
Solutions:
-
Verify environment variables:
# Check if variables are set docker exec selfhosteddb env | grep AUTH -
Check for typos:
- Verify
AUTH_USERandAUTH_PASSare correct - Check for extra spaces or special characters
- Ensure no quotes in environment variables (unless needed)
- Verify
-
Test authentication:
# Test Basic Auth curl -u admin:secret http://localhost:3001/api/health -
Clear browser cache:
- Clear cookies and cached credentials
- Try incognito/private browsing mode
-
Check API key (if using):
- Verify API key is correct
- Check if API key is active
- Ensure Bearer token format:
Authorization: Bearer <key>
Related: See API Documentation for authentication details
Issue: "API key not found" or "Invalid API key"
Symptoms:
- API requests fail with 401
- Error message about invalid API key
Solutions:
-
Verify API key format:
- Should be 64 characters (hex string)
- Use Bearer token:
Authorization: Bearer <key>
-
Check API key is active:
- Verify key exists in database
- Check
is_activeflag is true
-
Verify schema association:
- Ensure API key is associated with correct schema
- Check schema name matches
Related: See API Documentation for API key setup
Application Won't Start
Issue: Container exits immediately
Symptoms:
- Docker container starts then stops
docker psshows no running container
Solutions:
-
Check logs:
docker logs selfhosteddb # or docker-compose logs app -
Verify environment variables:
# Check required variables are set docker run --rm your-image env | grep -E "DATABASE_URL|AUTH_USER|AUTH_PASS" -
Check port conflicts:
# Check if port 3001 is already in use netstat -an | grep 3001 # or lsof -i :3001 -
Verify database connection:
- Ensure database is accessible
- Test connection string manually
-
Check Docker resources:
- Ensure sufficient memory/CPU
- Check Docker daemon is running
Issue: "Port already in use"
Symptoms:
- Error:
EADDRINUSE: address already in use :::3001 - Container fails to start
Solutions:
-
Find process using port:
# Linux/Mac lsof -i :3001 # Windows netstat -ano | findstr :3001 -
Stop conflicting process:
# Kill process (replace PID with actual process ID) kill -9 <PID> -
Use different port:
# Change PORT environment variable -e PORT=3002 # Update docker run command -p 3002:3002
Performance Issues
Issue: Slow query execution
Symptoms:
- Queries take >5 seconds
- Timeout errors
- High database CPU usage
Solutions:
-
Add database indexes:
-- Example: Add index on frequently queried column CREATE INDEX idx_users_email ON users(email); -
Optimize queries:
- Use
EXPLAIN ANALYZEto check query plans - Add WHERE clauses to limit results
- Use pagination (default limit is 50 rows)
- Use
-
Check connection pool:
- Monitor active connections
- Adjust pool size if needed (default: 20)
-
Review query timeout:
- Default timeout is 30 seconds
- Consider increasing for complex queries
Related: See Production Guide for performance tuning
Issue: High memory usage
Symptoms:
- Container OOM (Out of Memory) kills
- Slow response times
- High memory consumption
Solutions:
-
Increase container memory:
# docker-compose.yml services: app: deploy: resources: limits: memory: 2G -
Review query pagination:
- Ensure limits are enforced
- Reduce page size if needed
-
Check for memory leaks:
- Monitor memory over time
- Restart container if memory grows continuously
-
Optimize database queries:
- Add indexes
- Review query patterns
Docker Issues
Issue: "Cannot connect to Docker daemon"
Symptoms:
- Error:
Cannot connect to the Docker daemon - Docker commands fail
Solutions:
-
Start Docker service:
# Linux sudo systemctl start docker sudo systemctl enable docker # Windows/Mac: Start Docker Desktop -
Check Docker is running:
docker ps -
Add user to docker group (Linux):
sudo usermod -aG docker $USER # Log out and back in
Issue: "Image not found" or "Pull access denied"
Symptoms:
- Error pulling Docker image
- Image not found locally
Solutions:
-
Build image locally:
docker build -t selfhosteddb:latest . -
Pull from registry:
docker pull your-registry/selfhosteddb:latest -
Check registry credentials:
docker login your-registry
Issue: Docker Compose fails
Symptoms:
docker-compose upfails- Services don't start
Solutions:
-
Check docker-compose.yml syntax:
docker-compose config -
Verify all services are defined:
- Check service names match
- Verify image names are correct
-
Check dependencies:
# Ensure database service starts first docker-compose up db # Then start app docker-compose up app -
View detailed logs:
docker-compose logs -f
License Issues
Issue: "License required" or "A valid license or trial is required"
Symptoms:
- Error message:
License required - Application blocks access to features
- 403 Forbidden errors
Solutions:
-
Activate a license:
- Enter your license key and email address
- Click "Activate License"
- Verify activation was successful
-
Start a trial:
- Enter your email address
- Click "Start Free Trial"
- You'll have 14 days of full access
-
Check license status:
curl http://localhost:3001/api/license/status -
Verify LICENSE_SERVER_URL:
- Check
LICENSE_SERVER_URLenvironment variable is set - Ensure license server is accessible from your application
- Test connectivity:
curl https://your-license-server.com/api/health
- Check
-
Check grace period:
- Paid licenses: 7-day offline grace period
- Trials: 3-day offline grace period
- If grace period expired, reconnect to license server
Related: See Installation Guide for license activation steps
Issue: "License key not found" or "Invalid license key"
Symptoms:
- License activation fails
- Error:
License key not found or inactive - Validation returns
valid: false
Solutions:
-
Verify license key:
- Check you're using the correct license key from purchase email
- Ensure no extra spaces or characters
- Copy-paste directly from email
-
Verify email address:
- Use the exact email address associated with your purchase
- License keys are tied to purchaser's email (prevents sharing)
- Check purchase confirmation email for correct email
-
Check license server:
- Verify
LICENSE_SERVER_URLis correct - Ensure license server is accessible
- Check license server logs for errors
- Verify
-
Test validation:
curl -X POST http://localhost:3001/api/license/validate \ -H "Content-Type: application/json" \ -d '{"licenseKey": "your-key", "email": "your-email"}'
Related: See API Documentation for license endpoints
Issue: "License key does not match email address"
Symptoms:
- Error:
License key does not match this email address - Activation fails even with valid license key
Solutions:
-
Use correct email:
- License keys are tied to the purchaser's email address
- Use the exact email address from your purchase
- Check purchase confirmation email
-
Verify purchase:
- Ensure you're using the license key from your purchase
- Different purchases have different email addresses
- Contact support if email doesn't match
Note: This is by design to prevent license sharing. Same owner can deploy on unlimited machines.
Issue: "Trial expired" or "Trial not found"
Symptoms:
- Trial period has ended
- Application blocks access
- Error:
Trial expired
Solutions:
-
Purchase a license:
- Visit the purchase page
- Complete purchase
- Activate your license key
- Trial automatically converts to license
-
Check trial status:
curl http://localhost:3001/api/trial/status -
Start new trial (if eligible):
- Some users may be eligible for a new trial
- Check trial eligibility with license server
Related: See Installation Guide for license activation
Issue: "Cannot connect to license server"
Symptoms:
- Error:
ECONNREFUSEDor connection timeout - License validation fails
- Application uses grace period
Solutions:
-
Check LICENSE_SERVER_URL:
# Verify environment variable docker exec selfhosteddb env | grep LICENSE_SERVER_URL -
Test connectivity:
# Test license server accessibility curl https://your-license-server.com/api/health -
Check network/firewall:
- Ensure application can reach license server
- Check firewall rules allow outbound HTTPS
- Verify DNS resolution for license server
-
Use grace period:
- Application works offline for grace period (7 days paid, 3 days trial)
- Reconnect to license server before grace period expires
-
For development:
- Use local license server:
LICENSE_SERVER_URL=http://localhost:3002 - Ensure local license server is running
- Use local license server:
Related: See Production Guide for license server configuration
Error Messages Reference
Database Errors
| Error | Cause | Solution |
|---|---|---|
ECONNREFUSED | Database not running or unreachable | Start database, check connection string |
password authentication failed | Wrong credentials | Verify username/password |
database does not exist | Database name incorrect | Check database name in connection string |
connection timeout | Network issue or firewall | Check network connectivity, firewall rules |
SSL connection required | SSL not enabled | Add ?sslmode=require to connection string |
Application Errors
| Error | Cause | Solution |
|---|---|---|
EADDRINUSE | Port already in use | Change port or stop conflicting process |
ENOENT | File not found | Check file paths, verify files exist |
EACCES | Permission denied | Check file/directory permissions |
ECONNRESET | Connection reset | Check database is running, network issues |
API Errors
| Error | Cause | Solution |
|---|---|---|
401 Unauthorized | Invalid credentials | Check AUTH_USER/AUTH_PASS or API key |
403 Forbidden | License required | Activate license or start trial |
404 Not Found | Endpoint doesn't exist | Verify API endpoint path |
500 Internal Server Error | Server error | Check server logs for details |
400 Bad Request | Invalid request | Verify request format, parameters |
License Errors
| Error | Cause | Solution |
|---|---|---|
License key not found | Invalid or inactive license key | Verify license key from purchase email |
License key does not match email | Email doesn't match purchase | Use exact email from purchase |
Trial expired | Trial period ended | Purchase license to continue |
Cannot connect to license server | Network/firewall issue | Check LICENSE_SERVER_URL and connectivity |
Getting Help
If you're still experiencing issues:
-
Check logs:
# Docker logs docker logs selfhosteddb # Application logs tail -f /var/log/selfhosteddb/app.log -
Verify configuration:
- Review environment variables
- Check database connection
- Verify network connectivity
-
Test components individually:
- Test database connection separately
- Test API endpoints with curl
- Verify Docker setup
-
Review documentation:
-
Common solutions:
- Restart containers:
docker-compose restart - Rebuild images:
docker-compose build --no-cache - Check for updates:
docker pull your-registry/selfhosteddb:latest
- Restart containers:
Related Documentation
- Installation Guide - Setup and configuration
- Production Guide - Production deployment
- API Documentation - API usage and errors
- Security Guide - Security configuration
Quick Links:
- Having installation issues? See Installation Guide
- Need production deployment help? See Production Guide
- API errors? Check API Documentation
- Security concerns? Review Security Guide
Last Updated: 2025-01-27