Common issues and their solutions for ChainFinity platform.
- Installation Issues
- Database Connection Issues
- Authentication Issues
- API Issues
- Blockchain Issues
- Frontend Issues
- Performance Issues
- Deployment Issues
Error:
Error: listen EADDRINUSE: address already in use :::8000
Solution:
# Find process using the port
lsof -ti:8000
# Kill the process
lsof -ti:8000 | xargs kill -9
# Or use a different port
export PORT=8001
uvicorn app.main:app --port 8001Error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
Solution:
# Clear npm cache
npm cache clean --force
# Remove node_modules and package-lock
rm -rf node_modules package-lock.json
# Reinstall with legacy peer deps
npm install --legacy-peer-deps
# Or use npm 6
npm install -g npm@6
npm installError:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed
Solution:
# Deactivate current environment
deactivate
# Remove virtual environment
rm -rf venv
# Create fresh virtual environment
python3.11 -m venv venv
source venv/bin/activate
# Upgrade pip
pip install --upgrade pip
# Install requirements
pip install -r requirements.txtError:
permission denied while trying to connect to the Docker daemon socket
Solution:
# Add user to docker group
sudo usermod -aG docker $USER
# Log out and log back in, or run:
newgrp docker
# Verify
docker psError:
asyncpg.exceptions.ConnectionDoesNotExistError: connection is closed
Solutions:
1. Check if PostgreSQL is running:
# Check status
pg_isready -h localhost -p 5432
# Start PostgreSQL (Linux)
sudo systemctl start postgresql
# Start PostgreSQL (macOS)
brew services start postgresql
# Start with Docker
docker-compose up -d postgres2. Verify connection string:
# Check .env file
cat code/backend/.env | grep DATABASE_URL
# Correct format:
# DATABASE_URL=postgresql+asyncpg://user:password@localhost:5432/chainfinity3. Check PostgreSQL logs:
# Linux
sudo tail -f /var/log/postgresql/postgresql-15-main.log
# Docker
docker logs chainfinity_postgres4. Test connection manually:
psql -h localhost -U postgres -d chainfinityError:
asyncpg.exceptions.InvalidCatalogNameError: database "chainfinity" does not exist
Solution:
# Create database
psql -h localhost -U postgres -c "CREATE DATABASE chainfinity;"
# Run migrations
cd code/backend
alembic upgrade headError:
redis.exceptions.ConnectionError: Error connecting to Redis
Solutions:
1. Check if Redis is running:
# Test connection
redis-cli ping
# Expected output: PONG
# Start Redis (Linux)
sudo systemctl start redis
# Start Redis (macOS)
brew services start redis
# Start with Docker
docker-compose up -d redis2. Verify Redis URL:
# Check .env file
cat code/backend/.env | grep REDIS_URL
# Correct format:
# REDIS_URL=redis://localhost:6379/03. Check Redis logs:
# Docker
docker logs chainfinity_redis
# System
sudo journalctl -u redisError:
{"detail":"Could not validate credentials"}
Solutions:
1. Token expired:
# Refresh token
import requests
response = requests.post(
'http://localhost:8000/api/v1/auth/refresh',
json={'refresh_token': refresh_token}
)
new_access_token = response.json()['access_token']2. Invalid SECRET_KEY:
# Generate new SECRET_KEY
openssl rand -hex 32
# Update .env
echo "SECRET_KEY=your_new_secret_key" >> code/backend/.env
# Restart backend3. Token format error:
# Correct format
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
# NOT: Authorization: eyJhbGci... (missing "Bearer ")Possible causes:
1. Account not activated:
-- Check user status
SELECT email, is_active, email_verified FROM users WHERE email = 'user@example.com';
-- Activate account
UPDATE users SET is_active = true WHERE email = 'user@example.com';2. Account locked:
-- Check lockout status
SELECT email, failed_login_attempts, locked_until FROM users WHERE email = 'user@example.com';
-- Unlock account
UPDATE users SET failed_login_attempts = 0, locked_until = NULL WHERE email = 'user@example.com';3. Password hash mismatch:
# Reset password through API
curl -X POST http://localhost:8000/api/v1/auth/reset-password \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com"}'Error:
{"detail":"Rate limit exceeded. Try again later."}
Solutions:
1. Wait and retry:
import time
import requests
max_retries = 3
for i in range(max_retries):
response = requests.get(url, headers=headers)
if response.status_code != 429:
break
time.sleep(60) # Wait 1 minute2. Adjust rate limit (development only):
# In .env
RATE_LIMIT_PER_MINUTE=1203. Use exponential backoff:
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
session = requests.Session()
retry = Retry(
total=3,
backoff_factor=0.3,
status_forcelist=[429, 500, 502, 503, 504]
)
adapter = HTTPAdapter(max_retries=retry)
session.mount('http://', adapter)
session.mount('https://', adapter)Error:
Access to XMLHttpRequest at 'http://localhost:8000/api/v1/...' from origin 'http://localhost:3000' has been blocked by CORS policy
Solutions:
1. Update CORS configuration:
# In .env
CORS_ORIGINS=http://localhost:3000,http://localhost:3001
# Restart backend2. Check CORS headers:
curl -H "Origin: http://localhost:3000" \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: Content-Type" \
-X OPTIONS \
http://localhost:8000/api/v1/portfolios \
-vError:
{
"success": false,
"error": "Validation error",
"details": [
{
"field": "body -> password",
"message": "ensure this value has at least 8 characters",
"type": "value_error.any_str.min_length"
}
]
}Solution: Ensure request body matches API schema requirements. Check API documentation for correct format.
# Incorrect
{"pass": "abc"}
# Correct
{"password": "SecureP@ss123"}Error:
Error: transaction reverted without a reason string
Solutions:
1. Check gas limit:
const tx = await contract.someFunction({
gasLimit: 500000, // Increase if needed
});2. Check require statements:
// Add detailed error messages
require(amount > 0, "Amount must be positive");
require(balance >= amount, "Insufficient balance");3. Debug with Hardhat console:
const hardhat = require("hardhat");
await hardhat.network.provider.send("hardhat_setLoggingEnabled", [true]);Error:
Error: insufficient funds for gas * price + value
Solutions:
1. Fund account:
# Get testnet ETH from faucet
# Sepolia: https://sepoliafaucet.com/
# Goerli: https://goerlifaucet.com/2. Lower gas price:
const tx = await contract.someFunction({
gasPrice: ethers.utils.parseUnits("20", "gwei"),
});Error:
Error: contract not deployed
Solution:
# Deploy contracts
cd code/blockchain
npx hardhat run scripts/deploy.js --network localhost
# Update contract addresses in .envError:
Error: network mismatch (chainId 1337, expected 1)
Solution:
// Check network in MetaMask or wallet
const network = await provider.getNetwork();
console.log("Connected to network:", network.chainId);
// Switch network programmatically
await window.ethereum.request({
method: "wallet_switchEthereumChain",
params: [{ chainId: "0x1" }], // Mainnet
});Error:
Module not found: Can't resolve 'react-router-dom'
Solution:
# Install missing dependency
cd web-frontend
npm install react-router-dom
# Or reinstall all dependencies
rm -rf node_modules package-lock.json
npm installPossible causes:
1. JavaScript error:
# Check browser console (F12)
# Look for error messages2. API connection failed:
# Verify backend is running
curl http://localhost:8000/health
# Check API URL in .env
cat web-frontend/.env | grep REACT_APP_API_URL3. Build issue:
# Clear cache and rebuild
cd web-frontend
rm -rf build node_modules
npm install
npm startError:
No Ethereum provider found. Install MetaMask.
Solutions:
1. Install MetaMask:
- Download from https://metamask.io/
2. Detect provider correctly:
const detectProvider = async () => {
if (window.ethereum) {
return window.ethereum;
}
// Wait for provider injection
let provider = null;
for (let i = 0; i < 10; i++) {
await new Promise((resolve) => setTimeout(resolve, 100));
if (window.ethereum) {
provider = window.ethereum;
break;
}
}
return provider;
};3. Request account access:
await window.ethereum.request({ method: "eth_requestAccounts" });Diagnosis:
# Check API response times
time curl -H "Authorization: Bearer $TOKEN" \
http://localhost:8000/api/v1/portfoliosSolutions:
1. Enable caching:
# In .env
CACHE_TTL=3600 # Cache for 1 hour2. Optimize database queries:
# Use eager loading
from sqlalchemy.orm import selectinload
query = select(Portfolio).options(
selectinload(Portfolio.assets)
)3. Add database indexes:
CREATE INDEX idx_portfolios_user_id ON portfolios(user_id);
CREATE INDEX idx_transactions_user_id ON transactions(user_id);4. Check database connection pool:
# In .env
DB_POOL_SIZE=20
DB_MAX_OVERFLOW=30Diagnosis:
# Check process memory
ps aux | grep uvicorn
# Docker container memory
docker stats chainfinity_apiSolutions:
1. Limit worker processes:
# In production
WORKERS=4 # Not too many2. Optimize queries:
# Use pagination
limit = 20
offset = (page - 1) * limit
query = query.limit(limit).offset(offset)3. Clear cache regularly:
# Flush Redis cache
redis-cli FLUSHDBError:
ERROR [internal] load metadata for docker.io/library/python:3.11-slim
Solutions:
1. Check Docker daemon:
sudo systemctl status docker
sudo systemctl start docker2. Login to Docker registry:
docker login3. Pull base image manually:
docker pull python:3.11-slimError:
CrashLoopBackOff
Diagnosis:
# Check pod status
kubectl get pods -n chainfinity
# View pod logs
kubectl logs -f pod-name -n chainfinity
# Describe pod
kubectl describe pod pod-name -n chainfinityCommon solutions:
1. Missing environment variables:
# Update deployment.yaml with required env vars
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: chainfinity-secrets
key: database-url2. Resource limits too low:
resources:
requests:
memory: "512Mi"
cpu: "500m"
limits:
memory: "2Gi"
cpu: "2000m"Error:
alembic.util.exc.CommandError: Can't locate revision identified by 'abc123'
Solutions:
1. Check migration history:
cd code/backend
alembic history
alembic current2. Reset migrations (development only):
# Drop and recreate database
dropdb chainfinity
createdb chainfinity
# Run all migrations
alembic upgrade head3. Stamp database (if migrations already applied manually):
alembic stamp headIf you can't find a solution here:
-
Check logs:
# Backend logs tail -f logs/backend.log # Docker logs docker-compose logs -f # Kubernetes logs kubectl logs -f deployment/chainfinity-api -n chainfinity
-
Enable debug mode:
# In .env DEBUG=true LOG_LEVEL=DEBUG -
Search existing issues:
-
Create a new issue:
- Include error messages
- Include steps to reproduce
- Include environment details
- Include relevant logs
-
Join community:
- GitHub Discussions
- Project README for contact info
# Stop all services
docker-compose down
# Clear cache
redis-cli FLUSHDB
# Start fresh
docker-compose up -d
./scripts/run_chainfinity.sh# Check backend
curl http://localhost:8000/health
# Check database
pg_isready -h localhost
# Check Redis
redis-cli ping
# Check frontend
curl http://localhost:3000| Component | Log Location |
|---|---|
| Backend | logs/backend.log |
| Frontend | Browser console (F12) |
| PostgreSQL | /var/log/postgresql/ |
| Redis | /var/log/redis/ |
| Docker | docker logs <container> |
| Kubernetes | kubectl logs <pod> |