# Blockscout Logs Review Summary **Date**: December 23, 2025 **Container**: VMID 5000 on pve2 (192.168.11.140) **Status**: 🔴 **CRITICAL ISSUE - DATABASE MIGRATIONS NOT RUN** --- ## 🔴 Critical Issue Identified ### Root Cause **Blockscout database is empty - no tables exist. The application crashes on startup because it cannot find required database tables.** --- ## Key Findings ### 1. Database Status - ✅ **PostgreSQL Container**: Running and healthy - ❌ **Database Schema**: **EMPTY** - No tables exist - ❌ **Migration Status Table**: Does not exist (required by Blockscout) **Evidence**: ```bash docker exec blockscout-postgres psql -U blockscout -d blockscout -c '\dt' # Result: Did not find any relations. ``` ### 2. Blockscout Container Status - ✅ **Container**: Running (but constantly restarting) - ❌ **Application**: Crashes immediately on startup - ❌ **Phoenix Endpoint**: Never starts successfully **Container State**: `Up` but application exits with `shutdown` ### 3. Error Pattern Analysis #### Primary Errors: 1. **`ERROR 42P01 (undefined_table) relation "migrations_status" does not exist`** - Blockscout tries to check migration status before running migrations - This table doesn't exist because migrations haven't run 2. **`ERROR 42P01 (undefined_table) relation "blocks" does not exist`** - Application tries to query blocks table immediately on startup - Table doesn't exist because schema hasn't been created 3. **`ERROR 42P01 (undefined_table) relation "transactions" does not exist`** - Counters and background tasks try to query non-existent tables - Causes GenServer processes to terminate 4. **`could not lookup Ecto repo Explorer.Repo because it was not started or it does not exist`** - Application shutdown occurs before Ecto repo fully initializes - All database queries fail #### Application Lifecycle: ``` 1. Container starts 2. Blockscout application begins initialization 3. Ecto tries to start and query database 4. Queries fail (tables don't exist) 5. GenServers terminate with errors 6. Application shuts down: "Application explorer exited: shutdown" 7. Container restarts (if restart policy is set) ``` ### 4. Nginx Status - ✅ **Nginx Service**: Running and healthy - ❌ **Upstream Connection**: Fails (HTTP 502) - **Error**: `recv() failed (104: Unknown error) while reading response header from upstream` - **Cause**: Blockscout on port 4000 is not responding **Nginx Log Pattern**: - All requests return `502 Bad Gateway` - Upstream (`http://127.0.0.1:4000`) not available - Connection refused or prematurely closed ### 5. PostgreSQL Logs - ✅ **Connection Health**: Accepting connections - ❌ **Query Errors**: Constant stream of "relation does not exist" errors - **Pattern**: Blockscout tries to query tables → PostgreSQL returns error → Application crashes --- ## Missing Tables The following tables are expected but do not exist: - `migrations_status` (critical - tracks migration state) - `blocks` - `transactions` - `addresses` - `smart_contracts` - `token_instances` - `token_transfers` - `logs` - `internal_transactions` - `withdrawals` - ... (and many more) --- ## Impact 1. **Blockscout Web UI**: Not accessible (HTTP 502) 2. **API Endpoints**: Not responding 3. **Indexing**: Not running (requires database schema) 4. **External Access**: `https://explorer.d-bis.org` returns 502 --- ## Solution Required ### Immediate Action: Run Database Migrations Blockscout needs to run its database migrations before it can start. The migrations create all required tables. **Options**: 1. **Manual Migration** (Recommended): ```bash docker exec blockscout /app/bin/blockscout eval "Explorer.Release.migrate()" ``` 2. **Alternative**: Use Blockscout's built-in migration command: ```bash docker exec blockscout /app/bin/blockscout migrate ``` 3. **Check if auto-migration is enabled** in docker-compose.yml environment variables --- ## Next Steps 1. ✅ **Diagnosis Complete**: Database schema missing 2. ⏳ **Action Required**: Run database migrations 3. ⏳ **Verification**: Confirm tables are created 4. ⏳ **Test**: Verify Blockscout starts successfully 5. ⏳ **Monitor**: Check logs for successful startup --- ## Log Locations | Component | Location | Key Issues | |-----------|----------|------------| | Blockscout | `docker logs blockscout` | Missing tables, application shutdown | | PostgreSQL | `docker logs blockscout-postgres` | "relation does not exist" errors | | Nginx Error | `/var/log/nginx/error.log` | Upstream connection failures (502) | | Nginx Access | `/var/log/nginx/access.log` | All requests return 502 | --- ## Related Files - `BLOCKSCOUT_LOGS_REVIEW.md` - Detailed log analysis guide - `BLOCKSCOUT_SSL_COMPLETE_STATUS.md` - SSL setup status - `BLOCKSCOUT_CONFIGURATION_GUIDE.md` - Configuration details --- ## Summary **Status**: ❌ **BLOCKSCOUT NOT FUNCTIONAL** **Root Cause**: Database migrations have not been executed. Database is empty with no schema. **Impact**: Complete service outage - Blockscout cannot start without database tables. **Resolution**: Run database migrations to create required schema, then restart Blockscout. --- **Next Action**: Execute database migrations manually using Blockscout's migration command.