Description

Why do I get “no access to this vhost” when trying to start the RabbitMQ?

AuthorFullName__c
Shai Ben-Zvi
articleNumber
000004517
ft:sourceType
Salesforce
FirstPublishedDate
2019-08-08T13:53:59Z
lastModifiedDate
2024-03-10T07:45:52Z
VersionNumber
5

The RabbitMQ is one of the micro-services which is being used by Xray.
It is holding and managing all the messages of Xray in queues, which includes events, indexing, persists and analyzing messages.

The RabbitMQ queues, user permissions, policies, and connections are being managed by logical group of entities called ‘virtual hosts’.
When the server runs its first startup, it verifies if the database is uninitialized or has been deleted. A fresh database will start with the following resources:

  • A virtual host named / (a slash)

  • The default user has a full access to the / virtual host:
    Username: guest
    Password: guest
     

Additional information can be found in this external documentation page of RabbitMQ.
In case the startup fails, the following error will be displayed on the Xray server logs:

[2019/07/18 12:54:07 EDT] [EROR] (jfrog.com/xray/internal/xqueue/connector.connectToRabbitMQ:183) Error connecting to rabbit message queue check mq settings. Error: Exception (403) Reason: “no access to this vhost”

And on the RabbitMQ log, we will observe the following:

[error] <0.830.0> Error on AMQP connection <0.830.0> (127.0.0.1:54910 -> 127.0.0.1:5672, vhost: 'none', user: 'guest', state: opening), channel 0:
{handshake_error, opening, {amqp_error, internal_error, "access to vhost '/' refused for user 'guest': vhost '/' is down", 'connection.open'}}

Cause:

The error “no access to the vhost” on the RabbitMQ, may happen in case the user which runs the RabbitMQ doesn’t have any permissions configured for the vhost used (“/” by default), or in case RabbitMQ wasn’t shut down correctly (for example in case we ran out of disk space).

This can be tested by executing the following command:

$ curl --user guest:guest http://rabbitmq:15672/api/vhosts