I've been using Laravel Nightwatch for a few weeks, and it’s already become a must-have for monitoring my apps. Observability? Check. Easy setup? Check. But when I tried running multiple Laravel projects on the same server, I hit a classic snag:
RuntimeException: Failed to listen on "tcp://127.0.0.1:2407": Address already in use
Turns out, the fix is simple: give each Nightwatch agent its own port using the new --listen-on flag and the NIGHTWATCH_INGEST_URI environment variable.
Step 1: Assign Unique Ports
Every site needs its own agent. In your .env file, just pick a unique port per site:
In the .env file :
NIGHTWATCH_INGEST_URI=127.0.0.1:2408 # increase 2408 by 1 for every app
Step 2: Start the Agents
Just run each agent on its assigned port:
php artisan nightwatch:agent --listen-on=127.0.0.1:2408