Skip to main content

CAP.L0.AMBIGUOUS_READ_HOSTS — the connection offers several read hosts and nothing chose

  • Category: safety
  • Level: 0
  • Stability: stable
  • Suites: audit

One connection, several read hosts. Laravel resolves that by choosing at random: it shuffles the host list and picks the read and write sides independently, at connect time.

For an application that is exactly right — any replica will do. For an audit it is not.

Why it matters here and nowhere else

Server settings, replication lag and occasionally the schema itself differ between a primary and its replicas. A report that does not name the server it read is a report about an unknown database, and two runs of an unchanged project can disagree — a difference that reads as drift.

So SQLens does not choose. Either the configuration leaves exactly one possibility, or you name one, or the run stops.

What to do

Name the host:

php artisan sqlens:audit --host=replica-1.internal

…or settle it in config:

// config/sqlens.php
'host' => 'replica-1.internal',

A host the connection does not offer is refused rather than dialed — see unoffered host.