betfun-arena/PORT_CONFLICTS_FIXED.md

62 lines
1.8 KiB
Markdown

# ✅ Port Conflicts Fixed
## Issues Fixed
### 1. ✅ Port Already in Use Errors
**Problem**: Ports 3000, 3001, and 3002 were already in use by previous processes, causing services to fail on startup.
**Solutions Applied**:
1. **Kill Ports Script**: Created `scripts/kill-ports.sh` to automatically kill processes on ports 3000, 3001, 3002
2. **Auto-Kill on Start**: Updated `npm run dev` to automatically kill ports before starting services
3. **Better Error Handling**: Added error handlers to API and WebSocket services to show helpful messages when ports are in use
4. **Next.js Config**: Fixed workspace root warning by adding `outputFileTracingRoot`
### 2. ✅ Error Handling Improvements
- **API Service**: Now shows helpful error message and exit code when port is in use
- **WebSocket Service**: Now shows helpful error message and exit code when port is in use
- Both services provide command to kill the conflicting process
## New Scripts
### Kill Ports Manually
```bash
npm run kill-ports
# or
bash scripts/kill-ports.sh
```
### Start All Services (Auto-Kills Ports)
```bash
npm run dev
```
This now automatically kills ports 3000, 3001, 3002 before starting services.
## Service Status
All services should now start successfully:
- ✅ **Frontend**: http://localhost:3000
- ✅ **API**: http://localhost:3001
- ✅ **WebSocket**: http://localhost:3002
- ✅ **Indexer**: Background process
## Manual Port Management
If you need to kill ports manually:
```bash
# Kill specific port
lsof -ti :3000 | xargs kill -9
# Kill all app ports
lsof -ti :3000,3001,3002 | xargs kill -9
```
## Next.js Warning Fixed
The Next.js workspace root warning is now fixed by setting `outputFileTracingRoot` in `next.config.cjs`.
---
**Status**: 🟢 All Port Conflicts Resolved
**Auto-Fix**: ✅ Enabled (ports killed automatically on `npm run dev`)