Authentication Error
Login Issues
Access Refused
PLAIN Authentication Mechanism
IT Troubleshooting

RabbitMQ ACCESS_REFUSED: login was refused using authentication mechanism PLAIN

Codemia Knowledge Hub ·

"ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN" means the server rejected a username and password login. It is common with AMQP (Advanced Message Queuing Protocol) brokers such as RabbitMQ, where PLAIN is the simple username and password authentication mechanism. The usual cause is wrong credentials, but a disabled mechanism, account state, configuration or a TLS requirement can also trigger it.

How PLAIN authentication works

PLAIN sends the username and password over the network as plain text, optionally encrypted by the underlying protocol (such as TLS/SSL). The client sends a message containing:

  1. A protocol header, indicating this is a PLAIN login attempt.
  2. The username.
  3. The password.

These are usually packed into a single message with fields separated by a zero byte (\0), for example:

 
\x00username\x00password

This means an empty authorization identity ("use the authentication identity"), then the username, then the password.

Why the broker refuses the login

  1. Incorrect credentials: the most common cause. The username or password is wrong.
  2. PLAIN disabled: some servers turn PLAIN off for security, because it is weaker than alternatives such as SCRAM or certificate-based methods.
  3. Account status: the account is disabled, expired, or locked after repeated failed logins.
  4. Configuration issues: access control or user privileges are set up incorrectly on the server.
  5. TLS/SSL required: the server requires an encrypted connection and refuses logins over an insecure one.

Troubleshooting steps

  • Verify credentials: confirm the username and password are the ones the server expects.
  • Check the server configuration: in the configuration files or admin panel, make sure PLAIN authentication is enabled and configured correctly.
  • Check SSL/TLS: if the server requires it, make sure your connection is encrypted.
  • Review the account: confirm the user is active and not locked or disabled.
  • Read the logs: the server's error log often says why access was refused.

RabbitMQ configuration example

A RabbitMQ configuration file can include settings like these for authentication backends and SSL/TLS:

plaintext
1[
2  {rabbit, [
3    {auth_backends, [rabbit_auth_backend_internal]},
4    {ssl_listeners, [5671]},
5    {ssl_options, [{cacertfile,"path/to/testca/cacert.pem"},
6                   {certfile,"path/to/server/cert.pem"},
7                   {keyfile,"path/to/server/key.pem"},
8                   {verify,verify_peer},
9                   {fail_if_no_peer_cert,true}]}
10  ]}
11].

Here ssl_listeners opens a TLS port and ssl_options sets its certificates, so clients connecting on 5671 are encrypted.

Keep in mind that PLAIN transmits the password in clear text, so it can be intercepted unless the connection is encrypted.


Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design