# `Redix.ConnectionError`
[🔗](https://github.com/whatyouhide/redix/blob/v1.8.0/lib/redix/exceptions.ex#L18)

Error in the connection to Redis.

This exception represents errors in the connection to Redis: for example,
request timeouts, disconnections, and similar.

## Exception fields

See `t:t/0`.

## Error reasons

The `:reason` field can assume a few Redix-specific values:

  * `:closed`: when the connection to Redis is closed (and Redix is
    reconnecting) and the user attempts to talk to Redis

  * `:disconnected`: when the connection drops while a request to Redis is in
    flight.

  * `:timeout`: when Redis doesn't reply to the request in time.

  * `:health_check_timeout`: when the `:health_check_interval` option is set and an
    in-flight command goes unanswered for longer than that interval, so Redix closes
    the connection and reconnects.

  * `:no_replica_connection`: when a `Redix.Cluster` command with `route: :replica`
    finds no reachable replica for the slot, most often because the cluster wasn't
    started with `read_from_replicas: true`.

# `t`

```elixir
@type t() :: %Redix.ConnectionError{
  __exception__: true,
  reason: atom() | {:wrong_role, binary()}
}
```

The type for this exception struct.

This exception has the following public fields:

  * `:reason` - the error reason. It can be one of the Redix-specific
    reasons described in the "Error reasons" section below, or any error
    reason returned by functions in the `:gen_tcp` module (see the
    [`:inet.posix/0`](http://www.erlang.org/doc/man/inet.html#type-posix) type) or
    `:ssl` module.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
