Before starting, make sure:
- ✅ MongoDB is installed and running
- ✅ Node.js is installed (v16+)
- ✅ Dependencies are installed
Run these commands once:
# Install frontend dependencies
npm install
# Install backend dependencies
cd server
npm install
cd ..MongoDB is already running on your system! ✅
If you need to start it manually:
- Windows: MongoDB should be running as a service
- Mac:
brew services start mongodb-community - Linux:
sudo systemctl start mongod
Open a terminal and run:
cd server
npm startYou should see:
Connected to MongoDB successfully
Creating database indexes...
Database indexes created successfully
Server is running on http://localhost:5000
Keep this terminal open! Don't close it.
Open a NEW terminal (separate from backend) and run:
npm run devYou should see:
VITE v5.x.x ready in xxx ms
➜ Local: http://localhost:5173/
- Open your browser
- Go to
http://localhost:5173 - You should see the login/register screen
- Create an account and start using GitLife!
This means the backend server is not running!
Solution:
- Check if the backend terminal is running
- Make sure you see "Server is running on http://localhost:5000"
- If not, run
cd server && npm start - Refresh your browser
The backend server isn't running or can't be reached.
Solution:
- Start the backend server:
cd server && npm start - Check that it's running on port 5000
- Verify your
.envfile has:VITE_API_URL=http://localhost:5000/api
MongoDB isn't running.
Solution:
- Start MongoDB:
- Windows: Check Task Manager for "mongod" service
- Mac:
brew services start mongodb-community - Linux:
sudo systemctl start mongod
- Verify it's running:
mongosh(should connect)
Another application is using port 5000.
Solution:
- Find what's using port 5000:
- Windows:
netstat -ano | findstr :5000 - Mac/Linux:
lsof -i :5000
- Windows:
- Kill that process or change port in
server/.env:PORT=5001 - Also update frontend
.env:VITE_API_URL=http://localhost:5001/api
Check the error message in the terminal. Common issues:
- Missing dependencies: Run
cd server && npm install - MongoDB not accessible: Make sure MongoDB is running
- Wrong MongoDB URI: Check
server/.envhas correct URI
Check browser console (F12) for errors:
- CORS errors: Backend should have CORS enabled (it does)
- Network errors: Check Network tab, make sure requests go to
localhost:5000 - Backend errors: Check backend terminal for error messages
# Install all dependencies (first time)
npm install && cd server && npm install && cd ..
# Start backend (Terminal 1)
cd server && npm start
# Start frontend (Terminal 2)
npm run dev
# Check if MongoDB is running
mongosh
# Check what's on port 5000
netstat -ano | findstr :5000For faster development with auto-reload:
Backend (Terminal 1):
cd server
npm run dev # Uses nodemon for auto-reloadFrontend (Terminal 2):
npm run dev # Vite has hot-reload by default- Backend: Press
Ctrl+Cin the backend terminal - Frontend: Press
Ctrl+Cin the frontend terminal - MongoDB (optional):
- Usually leave it running
- To stop:
brew services stop mongodb-community(Mac) orsudo systemctl stop mongod(Linux)
Two terminals needed:
- Terminal 1: Backend server (
cd server && npm start) - Terminal 2: Frontend dev server (
npm run dev)
URLs:
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000/api
- MongoDB: mongodb://localhost:27017
Keep both terminals open while using the app!