> ## Documentation Index
> Fetch the complete documentation index at: https://docs.screenshothis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Troubleshooting

> Solve common issues when self-hosting Screenshothis with step-by-step solutions.

# Troubleshooting guide

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.

<Note>
  **Get the latest help**: Check the [Screenshothis repository](https://github.com/screenshothis/screenshothis) and [GitHub Issues](https://github.com/screenshothis/screenshothis/issues) for the most recent troubleshooting information and community solutions.
</Note>

## Quick diagnostics

Start here to quickly assess your system's health and identify issues:

<Steps>
  <Step title="Check application health">
    Test if your Screenshothis instance is responding:

    ```bash theme={null}
    # Basic health check
    curl -f http://localhost:3000/health

    # Detailed health status
    curl -s http://localhost:3000/health | jq '.'
    ```

    <Check>
      You should see a 200 response with health status information
    </Check>
  </Step>

  <Step title="Verify readiness">
    Check if the application is ready to serve requests:

    ```bash theme={null}
    # Check if application is ready
    curl -f http://localhost:3000/health/ready

    # Check if application is alive
    curl -f http://localhost:3000/health/live
    ```
  </Step>

  <Step title="Review recent logs">
    Examine logs for error messages and clues:

    ```bash theme={null}
    # View recent application logs
    docker logs screenshothis --tail 50

    # Follow logs in real-time
    docker logs -f screenshothis

    # View logs with timestamps
    docker logs -t screenshothis --since 1h
    ```
  </Step>
</Steps>

## Common startup issues

### Application won't start

When your Screenshothis instance fails to start or exits immediately:

<AccordionGroup>
  <Accordion title="Missing environment variables" icon="exclamation-triangle">
    **Symptoms**: Container exits immediately with environment variable errors

    **Diagnose the issue**:

    ```bash theme={null}
    # Check which variables are missing
    docker logs screenshothis 2>&1 | grep -i "missing\|required\|undefined"

    # Verify your environment file
    cat .env.production | grep -v '^#' | grep -v '^$'

    # List all environment variables in container
    docker exec screenshothis env | sort
    ```

    **Fix the problem**:

    1. Ensure all required variables are set in your `.env` file
    2. Key required variables include:
       * `DATABASE_URL`
       * `BETTER_AUTH_SECRET`
       * S3 configuration (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, etc.)
       * `VITE_SERVER_URL` (for frontend)

    ```bash theme={null}
    # Example fix - add missing variables
    echo "BETTER_AUTH_SECRET=$(openssl rand -base64 32)" >> .env.production
    echo "DEFAULT_API_KEY_PREFIX=ss_live" >> .env.production
    ```

    <Warning>
      Never use default development secrets in production. Generate unique, secure values for all secrets.
    </Warning>
  </Accordion>

  <Accordion title="Port already in use" icon="network-wired">
    **Symptoms**: `Error: listen EADDRINUSE: address already in use :::3000`

    **Diagnose and fix**:

    ```bash theme={null}
    # Check what's using port 3000
    sudo netstat -tulpn | grep :3000
    # Or use lsof
    sudo 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 environment
    echo "PORT=3001" >> .env.production
    ```

    **Prevention**: Use a reverse proxy like nginx to handle port 80/443 and proxy to your application.
  </Accordion>

  <Accordion title="Docker build failures" icon="package">
    **Symptoms**: Docker build fails with dependency or build errors

    **Diagnose and fix**:

    ```bash theme={null}
    # Clear Docker cache and rebuild
    docker system prune -f
    docker build --no-cache -t screenshothis:latest .

    # Build with verbose output for debugging
    docker build -t screenshothis:latest . 2>&1 | tee build.log

    # Check available disk space
    df -h

    # Clear unused Docker resources
    docker system df
    docker system prune -a
    ```

    **Common fixes**:

    * Ensure sufficient disk space (at least 2GB free)
    * Check internet connectivity for package downloads
    * Verify Node.js version compatibility
  </Accordion>
</AccordionGroup>

## Database connection problems

### PostgreSQL connectivity issues

When you can't connect to your PostgreSQL database:

<AccordionGroup>
  <Accordion title="Connection refused errors" icon="database">
    **Symptoms**: `Connection refused`, `Database does not exist`, or timeout errors

    **Diagnose the issue**:

    ```bash theme={null}
    # Test database connectivity directly
    psql "$DATABASE_URL" -c "SELECT version();"

    # Check if PostgreSQL container is running
    docker ps | grep postgres
    docker logs postgres-container

    # Test connection with individual components
    psql -h localhost -p 5432 -U screenshothis -d screenshothis
    ```

    **Fix the problem**:

    <Steps>
      <Step title="Verify PostgreSQL is running">
        ```bash theme={null}
        # Start PostgreSQL if stopped
        docker-compose up -d postgres

        # Check container health
        docker ps --filter "name=postgres"
        ```
      </Step>

      <Step title="Verify database exists">
        ```bash theme={null}
        # List available databases
        psql -h localhost -U screenshothis -l

        # Create database if missing
        createdb -h localhost -U screenshothis screenshothis
        ```
      </Step>

      <Step title="Test connection">
        ```bash theme={null}
        # Use the exact DATABASE_URL from your environment
        psql "$DATABASE_URL" -c "SELECT 1;"
        ```

        <Check>
          You should see a successful connection and query result
        </Check>
      </Step>
    </Steps>

    **Emergency reset** (⚠️ **This deletes all data**):

    ```bash theme={null}
    # Only use if you need to start fresh
    dropdb -h localhost -U screenshothis screenshothis
    createdb -h localhost -U screenshothis screenshothis
    pnpm run db:push
    ```
  </Accordion>

  <Accordion title="Migration and schema errors" icon="gear">
    **Symptoms**: Migration failed, schema errors, or table not found errors

    **Fix schema issues**:

    ```bash theme={null}
    # Check current schema status
    pnpm run db:studio

    # Apply schema changes (development)
    pnpm run db:push

    # For production, use migrations
    pnpm run db:generate
    pnpm run db:migrate

    # Reset schema (⚠️ destructive)
    pnpm run db:reset
    ```

    **Check migration status**:

    ```bash theme={null}
    # View migration history
    psql "$DATABASE_URL" -c "SELECT * FROM drizzle.__drizzle_migrations;"

    # Check table structure
    psql "$DATABASE_URL" -c "\dt"
    ```
  </Accordion>
</AccordionGroup>

## Redis connectivity issues

### Cache and session problems

When Redis connections fail or caching doesn't work:

<AccordionGroup>
  <Accordion title="Redis connection failed" icon="server">
    **Symptoms**: `Redis connection to localhost:6379 failed` or session issues

    **Diagnose and fix**:

    ```bash theme={null}
    # Check if Redis is running
    docker ps | grep redis
    docker logs redis-container

    # Test Redis connection directly
    redis-cli ping
    redis-cli -u "$REDIS_URL" ping

    # Start Redis if not running
    docker-compose up -d redis

    # Test with authentication if required
    redis-cli -a your-password ping
    ```

    **Verify Redis configuration**:

    ```bash theme={null}
    # Check Redis server info
    redis-cli info server

    # Test basic operations
    redis-cli set test "hello"
    redis-cli get test
    redis-cli del test
    ```
  </Accordion>

  <Accordion title="Authentication errors" icon="key">
    **Symptoms**: `NOAUTH Authentication required` or permission denied

    **Fix authentication**:

    ```bash theme={null}
    # Check if Redis requires authentication
    docker exec redis-container redis-cli config get requirepass

    # Update REDIS_URL with credentials
    export REDIS_URL="redis://username:password@localhost:6379"

    # Test authenticated connection
    redis-cli -u "$REDIS_URL" ping
    ```

    **Redis URL formats**:

    ```bash theme={null}
    # No authentication
    REDIS_URL=redis://localhost:6379

    # With password
    REDIS_URL=redis://:password@localhost:6379

    # With username and password
    REDIS_URL=redis://username:password@localhost:6379
    ```
  </Accordion>
</AccordionGroup>

## Storage and S3 issues

### Screenshot upload failures

When screenshots can't be saved to storage:

<AccordionGroup>
  <Accordion title="S3 access denied errors" icon="cloud">
    **Symptoms**: `AccessDenied`, `Forbidden`, or upload failure errors

    **Diagnose the issue**:

    ```bash theme={null}
    # Test S3 credentials and access
    aws s3 ls s3://your-bucket --region your-region

    # Check current AWS configuration
    aws configure list

    # Verify bucket exists and is accessible
    aws s3api head-bucket --bucket your-bucket
    ```

    **Fix permissions**:

    <Steps>
      <Step title="Verify credentials">
        Check that your AWS credentials are correct and active:

        ```bash theme={null}
        # Test basic AWS connectivity
        aws sts get-caller-identity

        # List accessible buckets
        aws s3 ls
        ```
      </Step>

      <Step title="Check bucket permissions">
        Ensure your IAM user has the required S3 permissions:

        ```json theme={null}
        {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Action": [
                "s3:GetObject",
                "s3:PutObject",
                "s3:DeleteObject"
              ],
              "Resource": "arn:aws:s3:::your-bucket/*"
            },
            {
              "Effect": "Allow",
              "Action": "s3:ListBucket",
              "Resource": "arn:aws:s3:::your-bucket"
            }
          ]
        }
        ```
      </Step>

      <Step title="Test upload">
        ```bash theme={null}
        # Test file upload
        echo "test" > test.txt
        aws s3 cp test.txt s3://your-bucket/test.txt
        aws s3 rm s3://your-bucket/test.txt
        rm test.txt
        ```

        <Check>
          Upload and deletion should complete without errors
        </Check>
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="MinIO local development issues" icon="hard-drive">
    **Symptoms**: MinIO connection fails or bucket access denied during local development

    **Fix MinIO issues**:

    <Steps>
      <Step title="Check MinIO status">
        ```bash theme={null}
        # Verify MinIO container is running
        docker ps | grep minio
        docker logs minio-container

        # Test MinIO health
        curl -f http://localhost:9000/minio/health/live
        ```
      </Step>

      <Step title="Access MinIO console">
        1. Open [http://localhost:9001](http://localhost:9001) in your browser
        2. Login with:
           * **Username**: `screenshothis-access-key`
           * **Password**: `screenshothis-secret-key`
        3. Create the bucket `screenshothis-bucket` if it doesn't exist
      </Step>

      <Step title="Reset MinIO if needed">
        ```bash theme={null}
        # Stop and remove MinIO data
        docker-compose down
        docker volume rm $(docker volume ls -q | grep minio)

        # Start fresh
        docker-compose up -d minio

        # Wait for startup, then create bucket via console
        ```
      </Step>
    </Steps>

    **Verify configuration**:

    ```bash theme={null}
    # Check environment variables match MinIO setup
    echo $AWS_ACCESS_KEY_ID      # Should be: screenshothis-access-key
    echo $AWS_SECRET_ACCESS_KEY  # Should be: screenshothis-secret-key
    echo $AWS_URL                # Should be: http://localhost:9000
    ```
  </Accordion>
</AccordionGroup>

## Screenshot generation problems

### Capture failures and timeouts

When screenshots fail to generate or take too long:

<AccordionGroup>
  <Accordion title="Screenshot timeouts" icon="clock">
    **Symptoms**: `Screenshot generation timed out` or requests timing out

    **Diagnose performance**:

    ```bash theme={null}
    # Monitor system resources
    docker stats screenshothis

    # Check screenshot processing logs
    docker logs -f screenshothis | grep -i screenshot

    # Monitor concurrent operations
    docker exec screenshothis ps aux | grep chrome
    ```

    **Optimize performance**:

    ```bash theme={null}
    # Increase timeout in environment variables
    echo "SCREENSHOT_TIMEOUT=60000" >> .env.production

    # Reduce concurrent screenshots if system is overloaded
    echo "MAX_CONCURRENT_SCREENSHOTS=5" >> .env.production

    # Optimize default screenshot settings
    echo "MAX_SCREENSHOT_WIDTH=1920" >> .env.production
    echo "MAX_SCREENSHOT_HEIGHT=1080" >> .env.production
    ```

    **System requirements**: Ensure adequate resources:

    * **CPU**: At least 2 cores for production
    * **RAM**: Minimum 2GB, recommended 4GB+
    * **Disk**: At least 5GB free space
  </Accordion>

  <Accordion title="Memory issues and crashes" icon="memory">
    **Symptoms**: Out of memory errors, container restarts, or system freezes

    **Monitor memory usage**:

    ```bash theme={null}
    # Check container memory usage
    docker stats screenshothis --no-stream

    # Check system memory
    free -h
    df -h
    ```

    **Fix memory issues**:

    <Tabs>
      <Tab title="Docker Compose">
        ```yaml theme={null}
        # In docker-compose.yml
        services:
          screenshothis:
            deploy:
              resources:
                limits:
                  memory: 2G
                reservations:
                  memory: 1G
        ```
      </Tab>

      <Tab title="Docker Run">
        ```bash theme={null}
        # Run with memory limits
        docker run -m 2g --memory-swap 2g screenshothis:latest
        ```
      </Tab>

      <Tab title="Kubernetes">
        ```yaml theme={null}
        # In deployment.yaml
        resources:
          requests:
            memory: "1Gi"
            cpu: "500m"
          limits:
            memory: "2Gi"
            cpu: "1000m"
        ```
      </Tab>
    </Tabs>

    **Memory optimization**:

    ```bash theme={null}
    # Reduce concurrent operations
    MAX_CONCURRENT_SCREENSHOTS=3

    # Enable garbage collection
    NODE_OPTIONS="--max-old-space-size=1024 --gc-interval=100"

    # Optimize Chrome memory usage
    CHROMIUM_ARGS="--memory-pressure-off --max_old_space_size=1024"
    ```
  </Accordion>

  <Accordion title="Chromium browser issues" icon="globe">
    **Symptoms**: Chromium fails to start, crashes, or sandbox errors

    **Common Chromium fixes**:

    <Steps>
      <Step title="Check security settings">
        For Docker deployments, you may need to adjust security settings:

        ```bash theme={null}
        # Run with additional security options
        docker run --security-opt seccomp=unconfined screenshothis

        # Or disable sandboxing (less secure)
        docker run --cap-add=SYS_ADMIN screenshothis
        ```
      </Step>

      <Step title="Verify dependencies">
        Ensure all required system dependencies are installed:

        ```dockerfile theme={null}
        # In your Dockerfile, install required packages
        RUN apt-get update && apt-get install -y \
            chromium \
            chromium-sandbox \
            fonts-liberation \
            libappindicator3-1 \
            libasound2 \
            libatk-bridge2.0-0 \
            libdrm2 \
            libgtk-3-0 \
            libnspr4 \
            libnss3 \
            libx11-xcb1 \
            libxcomposite1 \
            libxdamage1 \
            libxrandr2 \
            xdg-utils \
            && rm -rf /var/lib/apt/lists/*
        ```
      </Step>

      <Step title="Configure Chrome arguments">
        ```bash theme={null}
        # Add Chrome optimization flags
        CHROMIUM_ARGS="--no-sandbox --disable-dev-shm-usage --disable-extensions --disable-gpu"
        ```
      </Step>
    </Steps>

    **For Kubernetes deployments**:

    ```yaml theme={null}
    # Add security context to pod spec
    securityContext:
      runAsUser: 1001
      runAsGroup: 1001
      capabilities:
        add:
          - SYS_ADMIN
    ```
  </Accordion>
</AccordionGroup>

## Performance optimization

### System resource management

When your instance is slow or consuming too many resources:

<AccordionGroup>
  <Accordion title="High CPU and memory usage" icon="cpu">
    **Monitor resource consumption**:

    ```bash theme={null}
    # Real-time resource monitoring
    docker stats
    htop
    iostat 5

    # Check for memory leaks
    docker exec screenshothis node --expose-gc -e "
      console.log('Memory before GC:', process.memoryUsage());
      global.gc();
      console.log('Memory after GC:', process.memoryUsage());
    "
    ```

    **Optimization strategies**:

    <Tabs>
      <Tab title="Limit Concurrency">
        ```bash theme={null}
        # Reduce concurrent operations
        MAX_CONCURRENT_SCREENSHOTS=5
        RATE_LIMIT_MAX_REQUESTS=50
        RATE_LIMIT_WINDOW_MS=60000
        ```
      </Tab>

      <Tab title="Optimize Screenshots">
        ```bash theme={null}
        # Use more efficient settings
        DEFAULT_VIEWPORT_WIDTH=1280
        DEFAULT_VIEWPORT_HEIGHT=720
        MAX_PAGE_LOAD_TIMEOUT=15000
        SCREENSHOT_TIMEOUT=30000
        ```
      </Tab>

      <Tab title="Memory Management">
        ```bash theme={null}
        # Enable garbage collection and memory limits
        NODE_OPTIONS="--max-old-space-size=1024 --gc-interval=100"
        CHROMIUM_ARGS="--memory-pressure-off --disable-extensions"
        ```
      </Tab>
    </Tabs>
  </Accordion>

  <Accordion title="Slow screenshot generation" icon="image">
    **Diagnose slow performance**:

    ```bash theme={null}
    # Time screenshot generation
    time curl "http://localhost:3000/v1/screenshots/take?api_key=test&url=https://example.com"

    # Monitor Chrome processes
    docker exec screenshothis ps aux | grep chrome

    # Check system load
    uptime
    vmstat 5
    ```

    **Speed optimization**:

    ```bash theme={null}
    # Optimize browser settings for speed
    CHROMIUM_ARGS="--no-sandbox --disable-dev-shm-usage --disable-extensions --disable-images"

    # Reduce quality for faster generation
    DEFAULT_QUALITY=70
    MAX_SCREENSHOT_WIDTH=1920
    MAX_SCREENSHOT_HEIGHT=1080

    # Optimize page load timeout
    MAX_PAGE_LOAD_TIMEOUT=20000
    ```
  </Accordion>
</AccordionGroup>

## Network and connectivity

### External service connectivity

When you can't reach databases, S3, or other external services:

<AccordionGroup>
  <Accordion title="External service connectivity" icon="network-wired">
    **Test connectivity from your server**:

    ```bash theme={null}
    # Test database connectivity
    ping your-database-host
    telnet your-database-host 5432

    # Test S3 connectivity
    ping s3.amazonaws.com
    curl -I https://s3.amazonaws.com

    # Check DNS resolution
    nslookup your-database-host
    dig your-database-host

    # Test from within container
    docker exec screenshothis ping google.com
    docker exec screenshothis curl -v https://s3.amazonaws.com
    ```

    **Fix connectivity issues**:

    <Steps>
      <Step title="Check firewall rules">
        ```bash theme={null}
        # Check firewall status
        sudo ufw status

        # Allow outbound connections
        sudo ufw allow out 5432/tcp  # PostgreSQL
        sudo ufw allow out 6379/tcp  # Redis
        sudo ufw allow out 443/tcp   # HTTPS
        sudo ufw allow out 53/tcp    # DNS
        ```
      </Step>

      <Step title="Verify DNS resolution">
        ```bash theme={null}
        # Check DNS servers
        cat /etc/resolv.conf

        # Test DNS resolution
        nslookup your-service.com
        dig @8.8.8.8 your-service.com
        ```
      </Step>

      <Step title="Test with curl">
        ```bash theme={null}
        # Test HTTP connectivity
        curl -v https://your-service.com

        # Test with timeout
        curl --connect-timeout 10 https://your-service.com
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Firewall and security group issues" icon="shield">
    **Check and configure firewall rules**:

    <Tabs>
      <Tab title="UFW (Ubuntu)">
        ```bash theme={null}
        # Check current rules
        sudo ufw status numbered

        # Allow application ports
        sudo ufw allow 3000/tcp

        # Allow outbound database connections
        sudo ufw allow out 5432/tcp
        sudo ufw allow out 6379/tcp

        # Reset UFW if needed
        sudo ufw --force reset
        sudo ufw enable
        ```
      </Tab>

      <Tab title="iptables">
        ```bash theme={null}
        # Check current rules
        sudo iptables -L -n

        # Allow specific ports
        sudo iptables -A INPUT -p tcp --dport 3000 -j ACCEPT
        sudo iptables -A OUTPUT -p tcp --dport 5432 -j ACCEPT

        # Save rules (Ubuntu/Debian)
        sudo iptables-save > /etc/iptables/rules.v4
        ```
      </Tab>

      <Tab title="AWS Security Groups">
        ```bash theme={null}
        # Check security group rules
        aws ec2 describe-security-groups --group-ids sg-your-group-id

        # Add inbound rule for port 3000
        aws ec2 authorize-security-group-ingress \
          --group-id sg-your-group-id \
          --protocol tcp \
          --port 3000 \
          --cidr 0.0.0.0/0
        ```
      </Tab>
    </Tabs>
  </Accordion>
</AccordionGroup>

## Monitoring and diagnostics

### System health monitoring

Set up monitoring to prevent issues before they occur:

<Steps>
  <Step title="Enable health monitoring">
    Create monitoring scripts for system health:

    ```bash theme={null}
    # Health check script
    #!/bin/bash
    # save as health-check.sh

    echo "=== Screenshothis Health Check ==="
    echo "Timestamp: $(date)"

    # Check application health
    echo "Application health:"
    curl -f http://localhost:3000/health && echo " ✓ Healthy" || echo " ✗ Unhealthy"

    # Check disk space
    echo "Disk usage:"
    df -h | awk '$5 > 80 {print "WARNING: " $0}'

    # Check memory usage
    echo "Memory usage:"
    free -h

    # Check Docker containers
    echo "Container status:"
    docker ps --format "table {{.Names}}\t{{.Status}}"
    ```
  </Step>

  <Step title="Set up automated monitoring">
    Add monitoring to your crontab:

    ```bash theme={null}
    # Edit crontab
    crontab -e

    # Add these entries:
    # Health check every 5 minutes
    */5 * * * * /path/to/health-check.sh >> /var/log/screenshothis-health.log 2>&1

    # Disk space check every 15 minutes
    */15 * * * * df -h | awk '$5 > 85 {print "CRITICAL: Disk space low on " $0}' | mail -s "Disk Space Alert" admin@yourdomain.com

    # Log rotation check
    0 2 * * * docker logs screenshothis --tail 1000 > /var/log/screenshothis-daily.log
    ```
  </Step>

  <Step title="Monitor application metrics">
    Enable detailed application monitoring:

    ```bash theme={null}
    # Add metrics to environment
    echo "ENABLE_METRICS=true" >> .env.production
    echo "METRICS_PORT=9090" >> .env.production

    # View metrics
    curl http://localhost:9090/metrics

    # Monitor specific endpoints
    watch -n 5 'curl -s http://localhost:3000/health | jq .'
    ```
  </Step>
</Steps>

## Getting help and support

When you need additional assistance:

<CardGroup cols={2}>
  <Card title="GitHub Issues" icon="github" href="https://github.com/screenshothis/screenshothis/issues">
    Search existing issues or create a new one with detailed error information
  </Card>

  <Card title="Community Discussions" icon="message-circle" href="https://github.com/screenshothis/screenshothis/discussions">
    Join community discussions for questions and ideas
  </Card>

  <Card title="Documentation" icon="book" href="/self-host">
    Browse complete self-hosting documentation and guides
  </Card>

  <Card title="Configuration Reference" icon="settings" href="/self-host/configuration">
    Check all available configuration options and examples
  </Card>
</CardGroup>

### Collecting diagnostic information

When reporting issues, include this diagnostic information:

<Steps>
  <Step title="System information">
    ```bash theme={null}
    # Collect system details
    echo "=== System Information ===" > diagnostic.txt
    uname -a >> diagnostic.txt
    docker version >> diagnostic.txt
    docker-compose version >> diagnostic.txt
    lsb_release -a >> diagnostic.txt 2>/dev/null
    ```
  </Step>

  <Step title="Application logs">
    ```bash theme={null}
    # Collect recent application logs
    echo "=== Application Logs ===" >> diagnostic.txt
    docker logs screenshothis --tail 200 >> diagnostic.txt
    ```
  </Step>

  <Step title="Configuration (redacted)">
    ```bash theme={null}
    # Collect environment variables (remove sensitive data)
    echo "=== Environment Configuration ===" >> diagnostic.txt
    env | grep -v PASSWORD | grep -v SECRET | grep -v KEY | sort >> diagnostic.txt
    ```
  </Step>

  <Step title="Container status">
    ```bash theme={null}
    # Collect container information
    echo "=== Container Status ===" >> diagnostic.txt
    docker ps -a >> diagnostic.txt
    docker stats --no-stream >> diagnostic.txt
    ```
  </Step>
</Steps>

## Prevention and maintenance

### Regular maintenance tasks

Keep your Screenshothis instance healthy with regular maintenance:

<AccordionGroup>
  <Accordion title="Weekly maintenance" icon="calendar">
    **Perform these tasks weekly**:

    ```bash theme={null}
    # Clean up Docker resources
    docker system prune -f

    # Check log file sizes
    du -sh /var/log/
    docker logs screenshothis --tail 1 | wc -l

    # Update base images (when needed)
    docker pull postgres:15
    docker pull redis:7-alpine

    # Backup database
    pg_dump "$DATABASE_URL" > backup_$(date +%Y%m%d).sql
    ```
  </Accordion>

  <Accordion title="Monthly maintenance" icon="tools">
    **Perform these tasks monthly**:

    ```bash theme={null}
    # Update system packages
    sudo apt update && sudo apt upgrade -y

    # Check SSL certificate expiry
    echo | openssl s_client -connect yourdomain.com:443 2>/dev/null | openssl x509 -noout -dates

    # Review resource usage trends
    docker stats --no-stream
    df -h

    # Test backup restoration
    # (Test this in a separate environment)
    ```
  </Accordion>

  <Accordion title="Monitoring alerts" icon="bell">
    **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**:

    ```bash theme={null}
    #!/bin/bash
    # save as alert-check.sh

    # Check disk space
    DISK_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.com
    fi

    # Check if application is responding
    if ! curl -f http://localhost:3000/health >/dev/null 2>&1; then
        echo "ALERT: Screenshothis health check failed" | mail -s "Health Check Alert" admin@yourdomain.com
    fi
    ```
  </Accordion>
</AccordionGroup>

## Next steps

<CardGroup cols={2}>
  <Card title="Configuration Guide" icon="settings" href="/self-host/configuration">
    Optimize your configuration for better performance and reliability
  </Card>

  <Card title="Deployment Guide" icon="rocket" href="/self-host/deployment">
    Learn advanced deployment strategies and scaling options
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/introduction">
    Complete API documentation for your self-hosted instance
  </Card>

  <Card title="GitHub Repository" icon="github" href="https://github.com/screenshothis/screenshothis">
    Report issues and contribute to the project
  </Card>
</CardGroup>
