# Script to fix port 8000 conflict
Write-Host "Checking for processes using port 8000..." -ForegroundColor Cyan
Write-Host ""
$connection = Get-NetTCPConnection -LocalPort 8000 -ErrorAction SilentlyContinue
if ($connection) {
$processId = $connection.OwningProcess | Select-Object -Unique
$process = Get-Process -Id $processId -ErrorAction SilentlyContinue
if ($process) {
Write-Host "Found process using port 8000:" -ForegroundColor Yellow
Write-Host " Process: $($process.ProcessName)" -ForegroundColor White
Write-Host " PID: $processId" -ForegroundColor White
Write-Host " Command: $($process.Path)" -ForegroundColor Gray
Write-Host ""
$answer = Read-Host "Kill this process? (y/n)"
if ($answer -eq 'y' -or $answer -eq 'Y') {
Stop-Process -Id $processId -Force
Write-Host "[SUCCESS] Process killed. Port 8000 is now free." -ForegroundColor Green
Write-Host ""
Write-Host "You can now run: .\run-server.ps1" -ForegroundColor Cyan
} else {
Write-Host "Process not killed. Use a different port or kill it manually." -ForegroundColor Yellow
}
} else {
Write-Host "Could not get process details for PID $processId" -ForegroundColor Yellow
}
} else {
Write-Host "[INFO] No process found using port 8000" -ForegroundColor Green
Write-Host "The port should be free. Try running the server again." -ForegroundColor Cyan
}
Write-Host ""
Write-Host "Alternative: Use a different port" -ForegroundColor Yellow
Write-Host "Edit run-server.ps1 and change --port 8000 to --port 8001" -ForegroundColor Gray