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

Shai Ben-Zvi
Best_Article_1__c <recomsep> How To Recluster Rabbitmq Ha For Xray Ha
Best_Article_2__c <recomsep> Installing Xray
Best_Article_3__c <recomsep> Jfrog Xray Rabbitmq Queues
Best_Article_4__c <recomsep> System Requirements
Best_Article_5__c <recomsep> Artifactory System Yaml

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] ( 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> ( ->, 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", ''}}


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