Skip to content
Latchkey

RabbitMQ "NOT_FOUND - no exchange" in CI

The channel referenced an exchange that does not exist in the vhost. RabbitMQ closes the channel with a 404 NOT_FOUND. In CI this means the setup that declares the exchange did not run, or it ran against a different vhost.

What this error means

A publish or queue bind fails and the channel closes with "NOT_FOUND - no exchange 'events' in vhost '/'".

Terminal
Channel error on connection ... :
operation basic.publish caused a channel exception not_found:
no exchange 'events' in vhost '/'

Common causes

The exchange was never declared

No setup step declared the exchange, so the first publish to it fails with NOT_FOUND.

Declared in a different vhost

The exchange exists in another vhost, but the client connected to "/" (or vice versa), so it is not found here.

How to fix it

Declare the exchange before publishing

Declare it (idempotently) in a setup step or at client startup before any publish.

Terminal
rabbitmqadmin declare exchange name=events type=topic durable=true

Connect to the vhost that holds the exchange

Ensure the vhost in the AMQP URL matches where the exchange was declared.

Terminal
AMQP_URL=amqp://app:app_pw@localhost:5672/%2F

How to prevent it

  • Declare exchanges idempotently at startup before first use.
  • Keep the vhost consistent between declaration and publish.
  • Use a setup step to provision topology before tests run.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →