Port Already in Use

Fix "address already in use" errors when starting Moltbot.

Port Already in Use

Getting "address already in use" or "EADDRINUSE" errors? Another process is using the port Moltbot needs.

Symptoms

Error: listen EADDRINUSE: address already in use :::3000

or

Error starting server: port 3000 is already in use

Likely Causes

  1. Another Moltbot instance is running
  2. Different application using the same port
  3. Previous process didn't shut down cleanly
  4. Development server (Next.js, Vite, etc.) is running

Fix Steps

1. Find What's Using the Port

On Linux/macOS:

lsof -i :3000

On Windows:

netstat -ano | findstr :3000

2. Stop the Conflicting Process

If it's another Moltbot instance:

docker stop moltbot
docker rm moltbot

If it's another process (by PID):

kill -9 <PID>

3. Or Change Moltbot's Port

In your .env file:

PORT=3001  # Use a different port

In Docker:

docker run -p 3001:3000 moltbot/moltbot

In docker-compose.yml:

ports:
  - "3001:3000"

Verify

After fixing, verify nothing is using the port:

lsof -i :3000  # Should return nothing

Then start Moltbot:

docker-compose up -d
docker logs moltbot  # Check for successful startup

Prevent

  • Use unique ports for each service
  • Always stop containers before restarting: docker-compose down
  • Use docker-compose restart instead of up for restarts