# AMQPConnectionError: connection closed by server (530) NOT_ALLOWED

- **ID:** `communication/amqp-connection-530-not-allowed`
- **Domain:** communication
- **Category:** auth_error
- **Error Code:** `530`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

The AMQP client attempted to connect with insufficient permissions or an invalid virtual host (vhost) on the RabbitMQ broker.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| RabbitMQ 3.12.0 | active | — | — |
| pika 1.3.2 | active | — | — |
| amqplib 0.10.3 | active | — | — |

## Workarounds

1. **Verify and grant correct permissions for the user on the target vhost using RabbitMQ CLI: `rabbitmqctl set_permissions -p my_vhost my_user "^.*" "^.*" "^.*"` and ensure the vhost exists with `rabbitmqctl add_vhost my_vhost`.** (90% success)
   ```
   Verify and grant correct permissions for the user on the target vhost using RabbitMQ CLI: `rabbitmqctl set_permissions -p my_vhost my_user "^.*" "^.*" "^.*"` and ensure the vhost exists with `rabbitmqctl add_vhost my_vhost`.
   ```
2. **Configure the client connection string to explicitly specify the vhost: In Python with pika, use `pika.URLParameters('amqp://user:pass@host:5672/my_vhost')`.** (85% success)
   ```
   Configure the client connection string to explicitly specify the vhost: In Python with pika, use `pika.URLParameters('amqp://user:pass@host:5672/my_vhost')`.
   ```
3. **Check RabbitMQ logs for detailed rejection reason: `tail -f /var/log/rabbitmq/rabbit@host.log` to see if the error is due to vhost mismatch or user permissions.** (80% success)
   ```
   Check RabbitMQ logs for detailed rejection reason: `tail -f /var/log/rabbitmq/rabbit@host.log` to see if the error is due to vhost mismatch or user permissions.
   ```

## Dead Ends

- **Reinstall RabbitMQ server to reset permissions** — Reinstalling is overkill; the issue is typically a misconfigured vhost or user permissions, not a corrupt installation. (90% fail)
- **Use the default guest/guest credentials with default vhost '/'** — RabbitMQ disables guest user access from non-localhost by default; this fails for remote clients. (80% fail)
- **Increase the connection timeout in the client** — The error is a rejection, not a timeout; increasing timeout doesn't change permission checks. (95% fail)
