Skip to content

Latest commit

 

History

History
157 lines (115 loc) · 3.28 KB

File metadata and controls

157 lines (115 loc) · 3.28 KB

🎉 Problem Solved - Port Conflict Issue

❌ Original Problem:

Error: listen EADDRINUSE: address already in use :::5000
Error: Port 3000 is already in use
Error: Lock file exists (.next/dev/lock)

Root Cause:

  • 11 node processes background mein chal rahe the
  • Ports 3000 aur 5000 already busy the
  • Next.js lock file stuck thi
  • Purane dev servers properly band nahi hue the

✅ Solution Applied:

1. Killed All Node Processes

Get-Process -Name node | Stop-Process -Force

2. Cleaned Next.js Build Files

Remove-Item -Path "lms/.next" -Recurse -Force

3. Verified Ports Were Free

Test-NetConnection -Port 3000
Test-NetConnection -Port 5000

4. Started Fresh

npm run dev

✅ Current Status (VERIFIED & WORKING):

Component Status URL Response
Backend ✅ Running http://localhost:5000 HTTP 200 OK
Frontend ✅ Running http://localhost:3000 HTTP 200 OK
Health Check ✅ Working http://localhost:5000/api/health {"ok":true}
Node Processes ✅ Normal 11 processes (Backend + Frontend services)

🐳 Docker Containers:

Container Status Port Purpose
lms-postgres ✅ Running 5432 PostgreSQL Database
lms-mongodb ✅ Running 27017 MongoDB Database

🎯 How to Avoid This Issue in Future:

Proper Way to Stop Servers:

Option 1: Ctrl + C in Terminal

Press Ctrl + C jahan npm run dev chal raha hai

Option 2: Kill All Node Processes

Get-Process -Name node | Stop-Process -Force

Option 3: Kill Specific Port

# Find process using port
netstat -ano | findstr :3000
netstat -ano | findstr :5000

# Kill by PID
taskkill /PID <PID_NUMBER> /F

Before Starting Again:

# 1. Check if ports are free
netstat -ano | findstr ":3000 :5000"

# 2. If busy, kill processes
Get-Process -Name node | Stop-Process -Force

# 3. Clean Next.js cache (optional)
Remove-Item -Path "lms/.next" -Recurse -Force

# 4. Start fresh
npm run dev

📝 Quick Commands Reference:

Check Running Servers

# View all node processes
Get-Process -Name node

# Check specific ports
Test-NetConnection localhost -Port 3000
Test-NetConnection localhost -Port 5000

# See what's using ports
netstat -ano | findstr ":3000 :5000"

Stop Servers

# Stop all node processes
Get-Process -Name node | Stop-Process -Force

# Stop specific PID
Stop-Process -Id <PID> -Force

Start Servers

# From root directory
npm run dev

# OR individually
npm run dev:backend
npm run dev:frontend

🔧 Troubleshooting Checklist:

  • Check node processes: Get-Process -Name node
  • Check ports: netstat -ano | findstr ":3000 :5000"
  • Kill processes: Get-Process -Name node | Stop-Process -Force
  • Clean cache: Remove-Item "lms/.next" -Recurse -Force
  • Start fresh: npm run dev

✅ Everything Working Now!

  • ✅ Backend API responding
  • ✅ Frontend loading
  • ✅ No port conflicts
  • ✅ Docker containers running
  • ✅ Both databases connected

Happy Coding! 🚀