# Script to help fix Neo4j Aura connection issues
Write-Host "Neo4j Aura Connection Troubleshooter" -ForegroundColor Cyan
Write-Host ""
# Check current .env settings
if (Test-Path .env) {
Write-Host "Current Neo4j settings:" -ForegroundColor Yellow
Get-Content .env | Select-String 'NEO4J'
Write-Host ""
}
Write-Host "Common Issues and Solutions:" -ForegroundColor Cyan
Write-Host ""
Write-Host "1. IP ADDRESS NOT WHITELISTED (Most Common)" -ForegroundColor Yellow
Write-Host " Neo4j Aura requires your IP to be whitelisted." -ForegroundColor White
Write-Host ""
Write-Host " Solution:" -ForegroundColor Green
Write-Host " a) Go to: https://console.neo4j.io/" -ForegroundColor White
Write-Host " b) Select your database" -ForegroundColor White
Write-Host " c) Go to 'Network' or 'IP Whitelist' section" -ForegroundColor White
Write-Host " d) Click 'Add IP Address' or 'Allow All'" -ForegroundColor White
Write-Host " e) Add your current IP address" -ForegroundColor White
Write-Host ""
# Get current public IP
Write-Host " Your current public IP (check if it's whitelisted):" -ForegroundColor Cyan
try {
$ip = (Invoke-WebRequest -Uri "https://api.ipify.org" -UseBasicParsing).Content
Write-Host " $ip" -ForegroundColor Green
} catch {
Write-Host " Could not retrieve IP. Check manually at: https://www.whatismyip.com/" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "2. FIREWALL BLOCKING CONNECTION" -ForegroundColor Yellow
Write-Host " Your firewall might be blocking port 7687" -ForegroundColor White
Write-Host ""
Write-Host " Solution:" -ForegroundColor Green
Write-Host " - Temporarily disable firewall to test" -ForegroundColor White
Write-Host " - Or allow Python/neo4j through firewall" -ForegroundColor White
Write-Host ""
Write-Host "3. DATABASE PAUSED OR STOPPED" -ForegroundColor Yellow
Write-Host " Check if your Aura database is running" -ForegroundColor White
Write-Host ""
Write-Host " Solution:" -ForegroundColor Green
Write-Host " - Go to: https://console.neo4j.io/" -ForegroundColor White
Write-Host " - Check database status (should be 'Running')" -ForegroundColor White
Write-Host " - If paused, click 'Resume' or 'Start'" -ForegroundColor White
Write-Host ""
Write-Host "4. WRONG URI FORMAT" -ForegroundColor Yellow
Write-Host " Make sure you're using the correct URI format" -ForegroundColor White
Write-Host ""
Write-Host " Correct format:" -ForegroundColor Green
Write-Host " neo4j+s://xxxxx.databases.neo4j.io" -ForegroundColor White
Write-Host ""
Write-Host " Common mistakes:" -ForegroundColor Red
Write-Host " - Using bolt:// instead of neo4j+s://" -ForegroundColor White
Write-Host " - Missing +s in the protocol" -ForegroundColor White
Write-Host " - Wrong domain name" -ForegroundColor White
Write-Host ""
Write-Host "5. TEST CONNECTION" -ForegroundColor Yellow
Write-Host " Test if you can reach Neo4j:" -ForegroundColor White
Write-Host ""
$testConnection = Read-Host "Would you like to test the connection now? (y/n)"
if ($testConnection -eq 'y' -or $testConnection -eq 'Y') {
Write-Host ""
Write-Host "Testing connection..." -ForegroundColor Cyan
python -c "from neo4j import GraphDatabase; import os; from dotenv import load_dotenv; load_dotenv(); uri = os.getenv('NEO4J_URI'); user = os.getenv('NEO4J_USER'); pwd = os.getenv('NEO4J_PASSWORD'); driver = GraphDatabase.driver(uri, auth=(user, pwd)); driver.verify_connectivity(); print('SUCCESS: Connected to Neo4j!'); driver.close()"
}
Write-Host ""
Write-Host "For more help, see: NEO4J_SETUP.md" -ForegroundColor Cyan