quantum-ai-v3/ALLOWED_HOSTS_FIX.md

2.1 KiB

🎉 Success! Django is Running - Quick ALLOWED_HOSTS Fix

Great News!

  • Django is starting successfully (no more "service unavailable")
  • Gunicorn is running and responding to requests
  • 400 Bad Request = Django rejecting health check due to ALLOWED_HOSTS

🔧 Quick Fix - Update ALLOWED_HOSTS

Step 1: Get Your Railway Domain

Check your Railway project dashboard or URL bar for the exact domain, it looks like:

your-project-name-production-1234.up.railway.app

Step 2: Set ALLOWED_HOSTS in Railway Variables

Go to Railway → Variables → Add/Update:

Option A: Specific Domain

ALLOWED_HOSTS=your-exact-railway-domain.railway.app,quantumtaskai.com

Option B: Railway Wildcard (Recommended)

ALLOWED_HOSTS=*.railway.app,quantumtaskai.com,localhost

Option C: Debug Mode (Temporary)

ALLOWED_HOSTS=*

Step 3: Railway Will Auto-Redeploy

  • Railway automatically redeploys when environment variables change
  • Wait 30-60 seconds for redeploy
  • Health check should then pass

🎯 Expected Results

Before Fix (Current):

<!doctype html>
<html lang="en">
<head><title>Bad Request (400)</title></head>
<body><h1>Bad Request (400)</h1><p></p></body>
</html>

After Fix:

{
  "status": "healthy",
  "app": "quantum-tasks-ai", 
  "checks": {
    "application": {"status": "healthy", "django_ready": true},
    "environment": {"status": "healthy", "secret_key_configured": true}
  }
}

🚀 Next Steps After Fix

  1. Verify health check passes: Should return JSON instead of HTML
  2. Test application access: Visit Railway domain in browser
  3. Setup database: Run railway run python manage.py setup_database
  4. Test agents: All 6 AI agents should be available

🔍 Debug Commands

# Check your exact Railway domain
railway status

# Check current environment variables  
railway variables

# Test health endpoint
curl https://your-railway-domain/health/

# View logs
railway logs --tail 20

The hard part is done - Django is running! This is just a configuration fix. 🎯