Resolve common issues you might encounter when self-hosting Screenshothis. This guide provides step-by-step solutions, diagnostic commands, and prevention strategies to keep your instance running smoothly.
Never use default development secrets in production. Generate unique, secure values for all secrets.
Port already in use
Symptoms: Error: listen EADDRINUSE: address already in use :::3000Diagnose and fix:
# Check what's using port 3000sudo netstat -tulpn | grep :3000# Or use lsofsudo lsof -i :3000# Kill the process using the port (if safe to do so)sudo kill -9 $(sudo lsof -t -i:3000)# Alternative: Change the port in your environmentecho "PORT=3001" >> .env.production
Prevention: Use a reverse proxy like nginx to handle port 80/443 and proxy to your application.
Docker build failures
Symptoms: Docker build fails with dependency or build errorsDiagnose and fix:
# Clear Docker cache and rebuilddocker system prune -fdocker build --no-cache -t screenshothis:latest .# Build with verbose output for debuggingdocker build -t screenshothis:latest . 2>&1 | tee build.log# Check available disk spacedf -h# Clear unused Docker resourcesdocker system dfdocker system prune -a
When you can’t connect to your PostgreSQL database:
Connection refused errors
Symptoms: Connection refused, Database does not exist, or timeout errorsDiagnose the issue:
# Test database connectivity directlypsql "$DATABASE_URL" -c "SELECT version();"# Check if PostgreSQL container is runningdocker ps | grep postgresdocker logs postgres-container# Test connection with individual componentspsql -h localhost -p 5432 -U screenshothis -d screenshothis
Fix the problem:
1
Verify PostgreSQL is running
# Start PostgreSQL if stoppeddocker-compose up -d postgres# Check container healthdocker ps --filter "name=postgres"
2
Verify database exists
# List available databasespsql -h localhost -U screenshothis -l# Create database if missingcreatedb -h localhost -U screenshothis screenshothis
3
Test connection
# Use the exact DATABASE_URL from your environmentpsql "$DATABASE_URL" -c "SELECT 1;"
You should see a successful connection and query result
Emergency reset (⚠️ This deletes all data):
# Only use if you need to start freshdropdb -h localhost -U screenshothis screenshothiscreatedb -h localhost -U screenshothis screenshothispnpm run db:push
Migration and schema errors
Symptoms: Migration failed, schema errors, or table not found errorsFix schema issues:
# Check current schema statuspnpm run db:studio# Apply schema changes (development)pnpm run db:push# For production, use migrationspnpm run db:generatepnpm run db:migrate# Reset schema (⚠️ destructive)pnpm run db:reset
When Redis connections fail or caching doesn’t work:
Redis connection failed
Symptoms: Redis connection to localhost:6379 failed or session issuesDiagnose and fix:
# Check if Redis is runningdocker ps | grep redisdocker logs redis-container# Test Redis connection directlyredis-cli pingredis-cli -u "$REDIS_URL" ping# Start Redis if not runningdocker-compose up -d redis# Test with authentication if requiredredis-cli -a your-password ping
Verify Redis configuration:
# Check Redis server inforedis-cli info server# Test basic operationsredis-cli set test "hello"redis-cli get testredis-cli del test
Authentication errors
Symptoms: NOAUTH Authentication required or permission deniedFix authentication:
# Check if Redis requires authenticationdocker exec redis-container redis-cli config get requirepass# Update REDIS_URL with credentialsexport REDIS_URL="redis://username:password@localhost:6379"# Test authenticated connectionredis-cli -u "$REDIS_URL" ping
Redis URL formats:
# No authenticationREDIS_URL=redis://localhost:6379# With passwordREDIS_URL=redis://:password@localhost:6379# With username and passwordREDIS_URL=redis://username:password@localhost:6379
Symptoms: AccessDenied, Forbidden, or upload failure errorsDiagnose the issue:
# Test S3 credentials and accessaws s3 ls s3://your-bucket --region your-region# Check current AWS configurationaws configure list# Verify bucket exists and is accessibleaws s3api head-bucket --bucket your-bucket
Fix permissions:
1
Verify credentials
Check that your AWS credentials are correct and active:
# Test basic AWS connectivityaws sts get-caller-identity# List accessible bucketsaws s3 ls
2
Check bucket permissions
Ensure your IAM user has the required S3 permissions:
Create the bucket screenshothis-bucket if it doesn’t exist
3
Reset MinIO if needed
# Stop and remove MinIO datadocker-compose downdocker volume rm $(docker volume ls -q | grep minio)# Start freshdocker-compose up -d minio# Wait for startup, then create bucket via console
Verify configuration:
# Check environment variables match MinIO setupecho $AWS_ACCESS_KEY_ID # Should be: screenshothis-access-keyecho $AWS_SECRET_ACCESS_KEY # Should be: screenshothis-secret-keyecho $AWS_URL # Should be: http://localhost:9000
Symptoms: Chromium fails to start, crashes, or sandbox errorsCommon Chromium fixes:
1
Check security settings
For Docker deployments, you may need to adjust security settings:
# Run with additional security optionsdocker run --security-opt seccomp=unconfined screenshothis# Or disable sandboxing (less secure)docker run --cap-add=SYS_ADMIN screenshothis
2
Verify dependencies
Ensure all required system dependencies are installed:
When reporting issues, include this diagnostic information:
1
System information
# Collect system detailsecho "=== System Information ===" > diagnostic.txtuname -a >> diagnostic.txtdocker version >> diagnostic.txtdocker-compose version >> diagnostic.txtlsb_release -a >> diagnostic.txt 2>/dev/null
# Update system packagessudo apt update && sudo apt upgrade -y# Check SSL certificate expiryecho | openssl s_client -connect yourdomain.com:443 2>/dev/null | openssl x509 -noout -dates# Review resource usage trendsdocker stats --no-streamdf -h# Test backup restoration# (Test this in a separate environment)
Monitoring alerts
Set up alerts for:
Disk space > 85% full
Memory usage > 90%
Health check failures
SSL certificate expiry (30 days before)
High error rates in logs
Database connection failures
Example alert script:
#!/bin/bash# save as alert-check.sh# Check disk spaceDISK_USAGE=$(df / | awk 'NR==2 {print $5}' | sed 's/%//')if [ $DISK_USAGE -gt 85 ]; then echo "ALERT: Disk usage is ${DISK_USAGE}%" | mail -s "Disk Space Alert" admin@yourdomain.comfi# Check if application is respondingif ! curl -f http://localhost:3000/health >/dev/null 2>&1; then echo "ALERT: Screenshothis health check failed" | mail -s "Health Check Alert" admin@yourdomain.comfi