When RabbitMQ is installed via apt on Ubuntu, it automatically registers as a systemd service. The package comes with predefined unit files that configure it to start at boot. Here's how to verify the current status:
systemctl status rabbitmq-server.service
This will show whether the service is active (running) and enabled (set to start at boot).
To prevent RabbitMQ from starting automatically while keeping it installed:
sudo systemctl disable rabbitmq-server.service
This removes the symlinks from systemd's startup sequence without uninstalling the service.
After disabling autostart, you can manually control the service:
# Start when needed
sudo systemctl start rabbitmq-server.service
# Stop when finished
sudo systemctl stop rabbitmq-server.service
For more strict control (preventing even manual starts by accident):
sudo systemctl mask rabbitmq-server.service
To undo this later:
sudo systemctl unmask rabbitmq-server.service
Check if autostart is truly disabled:
systemctl is-enabled rabbitmq-server.service
This should return "disabled" or "masked" depending on your choice.
For developers who frequently need to toggle RabbitMQ, consider creating aliases or scripts:
#!/bin/bash
# ~/bin/rabbitmq-control
case "$1" in
start)
sudo systemctl start rabbitmq-server
;;
stop)
sudo systemctl stop rabbitmq-server
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
Make it executable:
chmod +x ~/bin/rabbitmq-control
After installing RabbitMQ on Ubuntu through apt or deb packages, the system automatically configures it as a systemd service that launches during boot. This behavior stems from the service file located at:
/lib/systemd/system/rabbitmq-server.service
Before making changes, verify the current status with:
systemctl status rabbitmq-server
This shows whether the service is active (running) and enabled (auto-starts on boot).
To prevent RabbitMQ from starting at boot while keeping the service installed:
sudo systemctl disable rabbitmq-server
This removes symlinks in the systemd directories while preserving the original service file.
For a more forceful prevention (useful when other services might try to start RabbitMQ as dependency):
sudo systemctl mask rabbitmq-server
This creates a symlink to /dev/null, making the service impossible to start accidentally.
When you need RabbitMQ, start it manually with:
sudo systemctl start rabbitmq-server
And stop it when finished:
sudo systemctl stop rabbitmq-server
After reboot, confirm RabbitMQ isn't running:
systemctl is-active rabbitmq-server
rabbitmqctl status
For more control, create an override:
sudo systemctl edit rabbitmq-server
Then add:
[Service]
Restart=no
[Install]
WantedBy=multi-user.target
To restore default behavior later:
sudo systemctl unmask rabbitmq-server
sudo systemctl enable rabbitmq-server