Running Multiple Laravel Nightwatch Agents on the same server

profile picture

Running Multiple Laravel Nightwatch Agents on the same server

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

Step 3: ???

Step 4: Profit !

laravel
server
nightwatch

about me

profile picture

I consider myself as an IT Business Artisan. Or Consultant CTO. I'm a self-taught Web Developper, coach and teacher. My main work is helping and guiding digital startups.

more about me

follow me

newsletter

A weekly email with the latests articles

support my work

Start trading on binance
  • BTC

    BTC

    bc1qgw9a8hyqqwvcls9ln7vhql4mad0qkveutr2td7

  • ETH

    ETH

    0x3A720717Da03dB6f3c4a4Ff08BC64100205A79d0

2025 © My Dynamic Production SRL All rights Reserved.