ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.
The client gets the same sentence whatever went wrong, with reply code 403, and the connection is closed. The reason is only in the broker log, as the message says. Measured on RabbitMQ 4.3.6 with pika 1.4.4:
| What the client did | Client sees | Broker log |
|---|---|---|
| wrong password | 403 ACCESS_REFUSED | PLAIN login refused: user 'app' - invalid credentials |
| user that does not exist | 403 ACCESS_REFUSED | PLAIN login refused: user 'nobody' - invalid credentials |
guest from another host | 403 ACCESS_REFUSED | PLAIN login refused: user 'guest' can only connect via localhost |
| right password, vhost without permissions | 530 NOT_ALLOWED - access to vhost '/' refused for user 'app' | access to vhost '/' refused for user 'app' |
| vhost name with a typo | 530 NOT_ALLOWED - vhost order not found | vhost order not found |
pika raises ProbableAuthenticationError for the first three and ProbableAccessDeniedError for the last two.
The log does not tell them apart: both are invalid credentials. Check the user exists (rabbitmqctl list_users), then the password your application really uses: when a setting is missing, Spring Boot and pika fall back to guest/guest.
By default RabbitMQ lets guest log in only over localhost. A connection from another container, a pod or the host through a Docker port mapping is not localhost to the broker: our client on the host arrived as 192.168.65.1 and was refused.
Two things make this confusing in Docker. The official rabbitmq image ships loopback_users.guest = false in /etc/rabbitmq/conf.d/10-defaults.conf, so guest works from anywhere there, and the same code fails on a broker installed another way. And with RABBITMQ_DEFAULT_USER set, the image creates that user instead, and guest does not exist at all.
Fix: create a user for each application and leave guest to local tests.
rabbitmqctl add_user billing 'a-long-password'
rabbitmqctl set_permissions -p orders billing '.*' '.*' '.*'
A 530 means the password was right and the user may not open that vhost, or the vhost does not exist. Most clients connect to / unless told otherwise, so a user that only has permissions on orders fails on /. Give the user permissions on the vhost (set_permissions -p), or put the vhost into the connection URL: amqp://billing:…@rabbit:5672/orders.