# Start Blockscout from pve2 Node

**You are currently on pve2 node. Follow these steps to start Blockscout:**

## Quick Start Commands

### Option 1: Enter Container and Start Service

```bash
# Enter the container
pct exec 5000 -- bash

# Check current status
systemctl status blockscout
docker ps -a | grep blockscout

# Start Blockscout service
systemctl start blockscout

# Check status
systemctl status blockscout

# Wait a moment, then test
sleep 10
curl http://127.0.0.1:4000/api/v2/status

# Exit container
exit
```

### Option 2: Start via Docker Compose

```bash
# Enter container
pct exec 5000 -- bash

# Navigate to Blockscout directory
cd /opt/blockscout

# Check if docker-compose.yml exists
ls -la docker-compose.yml

# Start services
docker-compose up -d
# OR if that doesn't work:
docker compose up -d

# Check containers
docker ps

# Wait for startup
sleep 30

# Test API
curl http://127.0.0.1:4000/api/v2/status

# Exit container
exit
```

### Option 3: Start Existing Docker Containers

```bash
# Enter container
pct exec 5000 -- bash

# List all containers (including stopped)
docker ps -a

# Find Blockscout containers
docker ps -a | grep blockscout

# Start them (replace <container-id> with actual IDs)
docker start <container-id>

# OR start all stopped containers
docker ps -a | grep blockscout | awk '{print $1}' | xargs docker start

# Check status
docker ps

# Test
sleep 15
curl http://127.0.0.1:4000/api/v2/status

# Exit container
exit
```

## One-Line Commands (Run from pve2)

### Start via systemd
```bash
pct exec 5000 -- systemctl start blockscout && sleep 10 && pct exec 5000 -- systemctl status blockscout
```

### Start via docker-compose
```bash
pct exec 5000 -- bash -c "cd /opt/blockscout && docker-compose up -d" && sleep 30 && pct exec 5000 -- curl -s http://127.0.0.1:4000/api/v2/status
```

### Check what's installed
```bash
pct exec 5000 -- bash -c "systemctl list-units | grep blockscout; echo '---'; ls -la /opt/blockscout/ 2>/dev/null | head -10; echo '---'; docker ps -a | grep blockscout"
```

## Troubleshooting

### If systemctl start fails:

**Check logs:**
```bash
pct exec 5000 -- journalctl -u blockscout -n 50
```

**Check if service file exists:**
```bash
pct exec 5000 -- systemctl list-unit-files | grep blockscout
pct exec 5000 -- cat /etc/systemd/system/blockscout.service 2>/dev/null || echo "Service file not found"
```

### If docker-compose fails:

**Check docker-compose.yml:**
```bash
pct exec 5000 -- cat /opt/blockscout/docker-compose.yml | head -50
```

**Check Docker:**
```bash
pct exec 5000 -- docker ps
pct exec 5000 -- docker-compose version
```

**Check PostgreSQL (Blockscout dependency):**
```bash
pct exec 5000 -- docker ps | grep postgres
pct exec 5000 -- docker-compose -f /opt/blockscout/docker-compose.yml up -d postgres
```

### If port 4000 still not accessible:

**Check if anything is listening:**
```bash
pct exec 5000 -- ss -tlnp | grep 4000
pct exec 5000 -- netstat -tlnp | grep 4000
```

**Check firewall:**
```bash
pct exec 5000 -- iptables -L -n | grep 4000
pct exec 5000 -- ufw status | grep 4000
```

## Verification

After starting, verify from pve2:

```bash
# Test direct port
curl http://192.168.11.140:4000/api/v2/status

# Test via Nginx proxy
curl http://192.168.11.140/api/v2/stats

# Both should return JSON, not 502 Bad Gateway
```

## Expected Output

**Successful API response:**
```json
{
  "success": true,
  "chain_id": 138,
  "block_number": "..."
}
```

**If you get 502 Bad Gateway:**
- Blockscout is not running on port 4000
- Check service status and logs
- Wait longer (Blockscout can take 1-2 minutes to start)

