How do I create or add a user to rabbitmq?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
RabbitMQ is a popular open-source message broker used to handle background jobs or asynchronous tasks by decoupling applications. Managing users in RabbitMQ is crucial for securing and limiting access to your message queues. This article explains how to create or add a user to RabbitMQ, along with setting permissions and understanding user roles.
Step 1: Installing RabbitMQ
Before adding users, ensure RabbitMQ is installed on your system. It is available for Windows, macOS, and Linux distributions. Installation guides can be found on the official RabbitMQ website.
Step 2: Accessing RabbitMQ Management Console
RabbitMQ provides a web-based management console, which can be accessed by installing the RabbitMQ management plugin. You can enable this plugin using the following command in the terminal:
After enabling the plugin, you can access the management console by navigating to http://localhost:15672/. The default username and password are guest.
Step 3: Creating a User
To add a user, you can use the RabbitMQ management console or the command-line interface. Here are the steps for both methods:
Using RabbitMQ Management Console:
- Log into the management console.
- Navigate to the "Admin" tab.
- In the "Users" section, click on "Add a user".
- Enter the username and password for the new user and click "Add user".
Using Command Line:
Open the terminal and run the following command:
Replace <username> and <password> with the desired user credentials.
Step 4: Setting User Permissions
After creating a user, you need to set permissions to specify what the user can access and do within RabbitMQ. Permissions can be set for virtual hosts. By default, a virtual host named / exists in RabbitMQ.
To set permissions using the command line:
This command grants the user full access to configure, write, and read operations within the default virtual host.
Step 5: Understanding User Roles
RabbitMQ supports various user roles, each allowing different levels of access and control:
- Administrator: Full access to all management features.
- Monitoring: Read-only access to monitoring features without configuration access.
- Management: Limited management capabilities, suitable for application developers.
- Policymaker: Can manage policies and parameters.
These roles can be applied from the management console or via the command line:
Step 6: Deleting or Updating Users
To update a user's password:
To delete a user:
Summary Table
Here is a summary of the key commands used:
| Action | Command | Description |
| Add User | rabbitmqctl add_user <username> <password> | Adds a new user with specified credentials. |
| Set Permissions | rabbitmqctl set_permissions -p / <username> ".*" ".*" ".*" | Sets permissions for a user on the default virtual host. |
| Set User Tags | rabbitmqctl set_user_tags <username> administrator | Assigns roles to a user. |
| Change Password | rabbitmqctl change_password <username> <new_password> | Updates the user's password. |
| Delete User | rabbitmqctl delete_user <username> | Deletes a user from RabbitMQ. |
Additional Details
Ensure that the credentials and permissions you assign to users align with your organization's security practices. Consider organizing users and permissions according to their roles and responsibilities within your workflows.
Adding users in RabbitMQ effectively is a critical step in securing and customizing the message broker for your application needs. By following the guidelines provided here, you can maintain strong access control and operational integrity in your RabbitMQ installation.

