Opensource Hosting Platform Wiki
Open-source hosting platform for servers, billing and support.
Brought to you by:
autobotsolution
This comprehensive troubleshooting guide covers common issues and their solutions for the HostingCo system.
# Check all services (verified working commands)
curl -s http://localhost:3003/api/health > /dev/null && echo "Backend: OK" || echo "Backend: DOWN"
curl -s http://localhost:3000 > /dev/null && echo "Frontend: OK" || echo "Frontend: DOWN"
# Check processes (actual output shows services running)
ps aux | grep -E "(node|vite)" | grep -v grep
# Check port usage (verified ports 3000 and 3003)
netstat -tlnp | grep -E ":300[03]"
# Backend logs (actual file locations)
tail -f backend/logs/combined.log
tail -f backend/logs/error.log
# Frontend logs (in development terminal)
# Check the terminal where npm run dev:frontend is running
# Vite outputs logs directly to terminal
# Process monitoring (verified commands)
ps aux | grep -E "(node|vite)" | grep -v grep
lsof -i :3000 # Frontend
lsof -i :3003 # Backend
# Check what's using ports
ss -tlnp | grep -E ":300[03]|:5432|:6379|:80|:443"
# Kill processes if needed
sudo kill -9 <PID>
# Alternative: change ports in .env files
Symptom: When trying to start services, they appear to be already running.
Verified Commands:
# Check current status (verified working)
curl http://localhost:3003/api/health
curl http://localhost:3000
# Check processes (actual output shows)
ps aux | grep -E "(node|vite)" | grep -v grep
# Solution: Services are working, no action needed
# If restart is required:
pkill -f "npm run dev"
pkill -f "vite"
pkill -f "node dist/index.js"
Symptom: Getting 401 errors for protected endpoints.
Verified Solution:
# Get authentication token
curl -X POST http://localhost:3003/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"admin@hostingco.com","password":"admin123"}'
# Use token in subsequent requests
curl http://localhost:3003/api/dashboard/stats \
-H "Authorization: Bearer <token>"
Symptom: Module not found errors.
Verified Solution:
# Install all dependencies (verified working)
npm run install:all
# Build shared packages first
cd shared && npm run build && cd ..
# Verify installation
ls node_modules
ls backend/node_modules
ls frontend/node_modules
# Error: EADDRINUSE: address already in use :::3003
# Solution 1: Kill existing process
sudo fuser -k 3003/tcp
# Solution 2: Change port
export PORT=3004
npm run dev:backend
# Solution 3: Find and kill process
lsof -ti:3003 | xargs kill -9
# Error: connect ECONNREFUSED 127.0.0.1:5432
# Check PostgreSQL status
sudo systemctl status postgresql
# Start PostgreSQL
sudo systemctl start postgresql
# Check connection string
echo $DATABASE_URL
# Test connection manually
psql -h localhost -U hostingco -d hostingco
# Reset database
cd backend
npm run db:reset
# Error: TSError: ⨯ Unable to compile TypeScript
# Clear TypeScript cache
rm -rf backend/node_modules/.cache
npm run dev:backend
# Check TypeScript version
npx tsc --version
# Update TypeScript
npm install typescript@latest
# Check for syntax errors
npx tsc --noEmit
# Error: Cannot find module 'express'
# Reinstall dependencies
cd backend
rm -rf node_modules package-lock.json
npm install
# Check package.json
cat package.json | grep -A 10 "dependencies"
# Install missing module
npm install express
# Check database queries
cd backend
npm run db:slow-queries
# Monitor CPU usage
top -p $(pgrep -f "node.*backend")
# Check memory usage
ps aux | grep node | grep backend
# Restart backend
npm run restart:backend
# Check memory usage
node --inspect backend/dist/index.js
# Monitor with PM2
pm2 monit
# Restart to clear memory
pm2 restart backend
# Check for memory leaks
npm run test:memory
# Check error logs
tail -f backend/logs/error.log
# Check database connection
npm run db:test
# Validate environment variables
printenv | grep -E "(DATABASE|REDIS|JWT)"
# Test with curl
curl -v http://localhost:3003/api/health
# Check JWT secret
echo $JWT_SECRET
# Verify token format
node -e "console.log(require('jsonwebtoken').verify('your-token', 'your-secret'))"
# Reset user password
cd backend
npm run user:reset-password -- --email user@example.com --password newpassword
# Check user status
npm run user:status -- --email user@example.com
# Error: Port 3000 is already in use
# Kill existing process
sudo fuser -k 3000/tcp
# Change port in vite.config.ts
# server.port = 3001
# Or use environment variable
export PORT=3001
npm run dev:frontend
# Error: Network Error
# Check backend status
curl http://localhost:3003/api/health
# Check API URL in frontend/.env
cat frontend/.env | grep VITE_API_URL
# Update API URL
echo "VITE_API_URL=http://localhost:3003/api" >> frontend/.env
# Restart frontend
npm run dev:frontend
# Error: Cannot resolve module
# Clear Vite cache
rm -rf frontend/node_modules/.vite
npm run dev:frontend
# Check imports
grep -r "import.*from" frontend/src/
# Reinstall dependencies
cd frontend
rm -rf node_modules package-lock.json
npm install
# Error: Build failed
# Check TypeScript errors
cd frontend
npx tsc --noEmit
# Fix ESLint errors
npm run lint:fix
# Clean build
rm -rf dist
npm run build
# Check environment variables
printenv | grep VITE_
# Build for production
npm run build:prod
# Test build locally
npm run preview
# Check browser console
# Open DevTools (F12) and check Console tab
# Check for JavaScript errors
# Look for red error messages
# Clear browser cache
# Ctrl+Shift+R (hard refresh)
# Check network requests
# Go to Network tab and check for failed requests
# Error: Access-Control-Allow-Origin
# Check backend CORS configuration
grep -A 10 "cors" backend/src/index.ts
# Update CORS settings
# In backend/src/index.ts:
app.use(cors({
origin: ['http://localhost:3000', 'https://yourdomain.com'],
credentials: true
}));
# Restart backend
npm run restart:backend
# Error: connect ECONNREFUSED
# Check PostgreSQL status
sudo systemctl status postgresql
# Start PostgreSQL
sudo systemctl start postgresql
sudo systemctl enable postgresql
# Check configuration
sudo -u postgres psql -c "SHOW config_file;"
# Test connection
sudo -u postgres psql -c "\l"
# Error: database "hostingco" does not exist
# Create database
sudo -u postgres createdb hostingco
# Create user
sudo -u postgres createuser hostingco
sudo -u postgres psql -c "ALTER USER hostingco PASSWORD 'password';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE hostingco TO hostingco;"
# Run migrations
cd backend
npm run migrate
# Error: permission denied for database
# Check user permissions
sudo -u postgres psql -c "\du"
# Grant permissions
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE hostingco TO hostingco;"
# Reset permissions
sudo -u postgres psql -d hostingco -c "GRANT ALL ON SCHEMA public TO hostingco;"
# Check disk space
df -h
# Check database size
psql -h localhost -U hostingco -d hostingco -c "SELECT pg_size_pretty(pg_database_size('hostingco'));"
# Clean up old data
psql -h localhost -U hostingco -d hostingco -c "DELETE FROM activity_logs WHERE timestamp < NOW() - INTERVAL '90 days';"
# Vacuum database
psql -h localhost -U hostingco -d hostingco -c "VACUUM ANALYZE;"
# Error: Migration failed
# Check migration status
cd backend
npm run migrate:status
# Rollback migration
npm run migrate:rollback
# Run migration again
npm run migrate
# Check migration file
ls -la backend/migrations/
# Error: Seeding failed
# Check seed files
ls -la backend/seeds/
# Run specific seed
npm run seed:specific -- --file=users.js
# Reset and reseed
npm run db:reset
npm run seed
# Error: Redis connection failed
# Check Redis status
sudo systemctl status redis
# Start Redis
sudo systemctl start redis
sudo systemctl enable redis
# Test connection
redis-cli ping
# Check Redis memory usage
redis-cli info memory
# Clear Redis cache
redis-cli flushall
# Check Redis configuration
redis-cli config get maxmemory
# Restart Redis
sudo systemctl restart redis
# Error: SSL certificate problem
# Check certificate expiration
openssl x509 -in /etc/ssl/certs/yourdomain.crt -noout -dates
# Renew certificate
sudo certbot renew
# Generate new certificate
sudo certbot --nginx -d yourdomain.com
# Check certificate path
ls -la /etc/ssl/certs/
# Error: Mixed content warning
# Check HTTPS configuration
grep -A 10 "ssl" /etc/nginx/sites-available/hostingco
# Update asset URLs
# Ensure all resources use HTTPS
# Restart Nginx
sudo systemctl reload nginx
# Check token expiration
node -e "
const token = 'your-jwt-token';
const decoded = require('jsonwebtoken').decode(token);
console.log('Expires:', new Date(decoded.exp * 1000));
"
# Generate new token
curl -X POST http://localhost:3003/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","password":"password"}'
# Update JWT secret
echo "JWT_SECRET=new-secret-key" >> .env
# Check slow queries
psql -h localhost -U hostingco -d hostingco -c "
SELECT query, mean_time, calls, total_time
FROM pg_stat_statements
ORDER BY mean_time DESC
LIMIT 10;"
# Add indexes
psql -h localhost -U hostingco -d hostingco -c "CREATE INDEX CONCURRENTLY idx_table_column ON table(column);"
# Analyze tables
psql -h localhost -U hostingco -d hostingco -c "ANALYZE;"
# Check CPU usage
top -p $(pgrep -f "node")
# Monitor with htop
htop
# Check Node.js process
ps aux | grep node
# Restart services
npm run restart:all
# Check memory usage
free -h
# Check Node.js memory
ps aux | grep node | awk '{print $4, $11}'
# Increase Node.js memory limit
export NODE_OPTIONS="--max-old-space-size=4096"
npm run dev:backend
# Monitor with PM2
pm2 monit
# Check DNS resolution
nslookup yourdomain.com
dig yourdomain.com
# Check /etc/hosts
cat /etc/hosts
# Flush DNS cache
sudo systemctl flush-dns # macOS
sudo systemctl restart systemd-resolved # Linux
# Check firewall status
sudo ufw status
# Allow ports
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 3003/tcp
# Check iptables
sudo iptables -L
# Check system resources
htop
iotop
nethogs
# Check disk usage
df -h
du -sh /var/log/
# Check network connections
netstat -tulpn
ss -tulpn
# Check application logs
tail -f backend/logs/app.log
tail -f backend/logs/error.log
# Check API health
curl -w "@curl-format.txt" -o /dev/null -s http://localhost:3003/api/health
# Monitor with PM2
pm2 status
pm2 logs
pm2 monit
# Check database connections
psql -h localhost -U hostingco -d hostingco -c "SELECT count(*) FROM pg_stat_activity;"
# Check database size
psql -h localhost -U hostingco -d hostingco -c "SELECT pg_size_pretty(pg_database_size('hostingco'));"
# Check slow queries
psql -h localhost -U hostingco -d hostingco -c "SELECT query, mean_time FROM pg_stat_statements ORDER BY mean_time DESC LIMIT 5;"
# 1. Stop all services
npm run stop:all
sudo systemctl stop postgresql redis nginx
# 2. Backup current state
cp -r /var/lib/postgresql /backups/postgres_$(date +%Y%m%d_%H%M%S)
cp -r /var/lib/redis /backups/redis_$(date +%Y%m%d_%H%M%S)
# 3. Restore from backup
psql -h localhost -U hostingco -d hostingco < backup_20260508_030000.sql
# 4. Start services
sudo systemctl start postgresql redis nginx
npm run start:all
# 5. Verify system
curl http://localhost:3003/api/health
curl http://localhost:3000
# Restore database from backup
pg_dump -h localhost -U hostingco hostingco > emergency_backup.sql
psql -h localhost -U hostingco -d hostingco < backup_20260508_030000.sql
# Verify data integrity
cd backend
npm run db:verify
System Information:
bash
uname -a
node --version
npm --version
psql --version
redis-cli --version
Error Messages:
Screenshots if applicable
System Status:
bash
systemctl status postgresql redis nginx
curl -s http://localhost:3003/api/health
Recent Changes:
Last updated: $(date)