docs/guides/TROUBLESHOOTING.md
This guide helps you diagnose and fix common issues before submitting a bug report.
Before reporting a bug, please check:
docker compose ps or ps aux | grep nofxcurl http://localhost:8080/api/healthSymptom: AI only opens short positions, never long positions, even when market is bullish.
Root Cause: Binance account is in One-way Mode instead of Hedge Mode.
Solution:
Why this happens:
PositionSide(LONG) and PositionSide(SHORT) parametersFor Subaccounts:
code=-4061 Position Side MismatchError Message: Order's position side does not match user's setting
Solution: Same as above - switch to Hedge Mode.
Subaccounts restricted to 5x leverageSymptom: Orders fail with leverage error when trying to use >5x leverage.
Solution:
{
"btc_eth_leverage": 5,
"altcoin_leverage": 5
}
Check these:
API Permissions:
Account Balance:
Symbol Status:
Decision Logs:
# Check latest decision
ls -lt decision_logs/your_trader_id/ | head -5
cat decision_logs/your_trader_id/latest_file.json
Possible Causes:
How to Check:
# View latest decision reasoning
cat decision_logs/your_trader_id/$(ls -t decision_logs/your_trader_id/ | head -1)
Look at the AI's Chain-of-Thought reasoning section.
Solutions:
use_default_coins: true or coin pool API is workingRemember: AI trading is experimental and not guaranteed to be profitable.
Things to Check:
Adjustments:
Error: ERROR [internal] load metadata for docker.io/library/...
Symptoms:
docker compose build or docker compose up hangstimeout, connection refusedRoot Cause: Access to Docker Hub is restricted or extremely slow in mainland China.
Solution 1: Configure Docker Registry Mirror (Recommended)
Edit Docker configuration file:
# Linux
sudo nano /etc/docker/daemon.json
# macOS (Docker Desktop)
# Settings โ Docker Engine
Add China registry mirrors:
{
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://docker.1panel.live",
"https://hub.rat.dev",
"https://dockerpull.com",
"https://dockerhub.icu"
]
}
Restart Docker:
# Linux
sudo systemctl restart docker
# macOS/Windows
# Restart Docker Desktop
Rebuild:
docker compose build --no-cache
docker compose up -d
Solution 2: Use VPN
docker compose buildSolution 3: Offline Image Download
If above methods don't work:
Use image proxy websites:
Manually import images:
# After downloading image files
docker load -i golang-1.25-alpine.tar
docker load -i node-20-alpine.tar
docker load -i nginx-alpine.tar
Verify images are loaded:
docker images | grep golang
docker images | grep node
docker images | grep nginx
Verify registry mirror is working:
# Check Docker info
docker info | grep -A 10 "Registry Mirrors"
# Should show your configured mirrors
Related Issue: #168
Error: port 8080 already in use
Solution:
# Find what's using the port
lsof -i :8080
# OR
netstat -tulpn | grep 8080
# Kill the process or change port in .env
NOFX_BACKEND_PORT=8081
Symptoms:
Solutions:
Check backend is running:
docker compose ps # Should show backend as "Up"
# OR
curl http://localhost:8080/api/health # Should return {"status":"ok"}
Check port configuration:
.env settings matchCORS Issues:
Common Errors:
code=-1021, msg=Timestamp for this request is outside of the recvWindowinvalid signaturetimestamp errorsRoot Cause: System time is inaccurate, differing from Binance server time by more than allowed range (typically 5 seconds).
Solution 1: Sync System Time (Recommended)
# Method 1: Use ntpdate (most common)
sudo ntpdate pool.ntp.org
# Method 2: Use other NTP servers
sudo ntpdate -s time.nist.gov
sudo ntpdate -s ntp.aliyun.com # Aliyun NTP (fast in China)
# Method 3: Enable automatic time sync (Linux)
sudo timedatectl set-ntp true
# Verify time is correct
date
# Should show current accurate time
Docker Environment Special Note:
If using Docker, container time may be out of sync with host:
# Check container time
docker exec nofx-backend date
# If time is wrong, restart Docker service
sudo systemctl restart docker
# Or add timezone in docker-compose.yml
environment:
- TZ=Asia/Shanghai # or your timezone
Solution 2: Verify API Keys
If errors persist after time sync:
Check API Keys:
Regenerate API Keys:
Solution 3: Check Rate Limits
Binance has strict API rate limits:
Related Issue: #60
Solutions:
Hard Refresh:
Ctrl+Shift+R (Windows/Linux) or Cmd+Shift+R (Mac)Cmd+Option+RClear Browser Cache:
Check SWR Polling:
Possible Causes:
Solutions:
database is locked ErrorCause: SQLite database being accessed by multiple processes.
Solution:
# Stop all NOFX processes
docker compose down
# OR
pkill nofx
# Restart
docker compose up -d
# OR
./nofx
Check:
PostgreSQL container health
docker compose ps postgres
docker compose exec postgres pg_isready -U nofx -d nofx
Inspect data directly
./scripts/view_pg_data.sh # quick overview
docker compose exec postgres \
psql -U nofx -d nofx -c "SELECT COUNT(*) FROM traders;"
Disk space
df -h # Ensure disk not full
Docker:
# View last 100 lines
docker compose logs backend --tail=100
# Follow live logs
docker compose logs -f backend
# Save to file
docker compose logs backend --tail=500 > backend_logs.txt
Manual binary:
# If running without Docker, the terminal running ./nofx prints logs
Open DevTools:
F12 or Right-click โ InspectConsole Tab:
Network Tab:
Capture Screenshot:
Win+Shift+SCmd+Shift+4# List recent decision logs
ls -lt decision_logs/your_trader_id/ | head -10
# View latest decision
cat decision_logs/your_trader_id/$(ls -t decision_logs/your_trader_id/ | head -1) | jq .
# Search for specific symbol
grep -r "BTCUSDT" decision_logs/your_trader_id/
# Find decisions that resulted in trades
grep -r '"action": "open_' decision_logs/your_trader_id/
What to look for in decision logs:
chain_of_thought: AI's reasoning processuser_prompt: Market data AI receiveddecision: Final decision (action, symbol, leverage, etc.)account_state: Account balance, margin, positions at decision timeexecution_result: Whether trade succeeded or failed# Backend health
curl http://localhost:8080/api/health
# List all traders
curl http://localhost:8080/api/traders
# Check specific trader status
curl http://localhost:8080/api/status?trader_id=your_trader_id
# Get account info
curl http://localhost:8080/api/account?trader_id=your_trader_id
# Check all containers
docker compose ps
# Check resource usage
docker stats
# Restart specific service
docker compose restart backend
docker compose restart frontend
# Check traders in database
docker compose exec postgres \
psql -U nofx -d nofx -c "SELECT id, name, ai_model_id, exchange_id, is_running FROM traders;"
# Check AI models
docker compose exec postgres \
psql -U nofx -d nofx -c "SELECT id, name, provider, enabled FROM ai_models;"
# Check system config
docker compose exec postgres \
psql -U nofx -d nofx -c "SELECT key, value FROM system_config;"
If you've tried all the above and still have problems:
Gather Information:
Submit Bug Report:
Join Community:
Complete Reset (โ ๏ธ Will lose trading history):
# Stop everything
docker compose down
# Optional: back up PostgreSQL data
docker compose exec postgres \
pg_dump -U nofx -d nofx > backup_nofx.sql
# Remove all persisted volumes (fresh start)
docker compose down -v
# Restart
docker compose up -d --build
# Reconfigure through web UI
open http://localhost:3000
Partial Reset (Keep configuration, clear logs):
# Clear decision logs
rm -rf decision_logs/*
# Clear Docker cache and rebuild
docker compose down
docker compose build --no-cache
docker compose up -d
Last Updated: 2025-11-02