# Reconnecting to the Primary Server with MaxScale's Read/Write Split Router

The Read/Write Split Router (readwritesplit) routes write queries to the primary server and load balances read-only queries between one or more replica servers. If the primary server fails, then the router can automatically reconnect existing client connections to the new primary server.

## Configuring Automatic Primary Server Re-connection

1. Configure automatic primary server re-connection by configuring several parameters for the Read/Write Split Router in maxscale.cnf.

| Parameter             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| master\_reconnection  | • When this parameter is enabled, if the primary server fails and if master\_failure\_mode is not set to fail\_instantly, then existing client connections will be automatically reconnected to the new primary server. • This parameter is disabled by default.                                                                                                                                                                                                                                                                                            |
| master\_failure\_mode | • This parameter defines how client connections are handled when the primary server fails. • This parameter must be set to either fail\_on\_write or error\_on\_write to allow automatic primary server reconnection. • When this parameter is set to fail\_on\_write, the client connection is closed if a write query is received when no primary is available. • When this parameter is set to error\_on\_write, if no primary server is available and a write query is received, an error is returned stating that the connection is in read-only mode. |

For example:

```
[split-router]
type                     = service
router                   = readwritesplit
...
master_reconnection            = true
master_failure_mode            = fail_on_write
```

2. Restart the MaxScale instance.

```
$ sudo systemctl restart maxscale
```

<sub>*This page is: Copyright © 2025 MariaDB. All rights reserved.*</sub>

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/maxscale/maxscale-use-cases/readwrite-split-router-usage/reconnecting-to-the-primary-server-with-maxscales-readwrite-split-router.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
