# CONFIG SET

> Change runtime configuration.

Use `CONFIG SET` to change runtime configuration parameters without restarting.

This deployment permits changes only to `notify-keyspace-events`, which selects the keyspace and keyevent notifications the server publishes: the value is a set of flag characters, such as `KEA` for everything, or `Kg$` for generic and string keyspace events. Any other parameter returns an error.

Several parameter and value pairs can be given in one call, and they are processed from left to right, so if a later pair is rejected an earlier change may already have taken effect.

## Syntax

```redis
CONFIG SET <parameter> <value> [parameter value ...]
```

## Arguments

| Argument | Required | Repeatable | Description |
| --- | --- | --- | --- |
| `parameter` | Yes | Yes, in pairs | Runtime configuration parameter to update. |
| `value` | Yes | Yes, in pairs | New value for the preceding parameter. |

## Important points

- This command can expose administrative information or make a broad destructive change. Restrict it to trusted code paths.
- This deployment permits changes only to `notify-keyspace-events`; any other parameter returns an error.
- Parameter/value pairs are processed from left to right. If a later pair is invalid, an earlier valid change may already have taken effect.

## Response

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.

| Protocol | Reply |
| --- | --- |
| RESP2 | Simple string `OK` |
| RESP3 | Simple string `OK` |

<Note>
  Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.
</Note>

## Examples

TCP examples use the TLS `REDIS_URL` from the Upstash console. REST examples use `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`.

<AccordionGroup>

<Accordion title="Redis CLI" icon="terminal">

```bash
CONFIG SET notify-keyspace-events Ex
```

</Accordion>

<Accordion title="@upstash/redis" icon="node-js" iconType="brands">

<Note>
  This command is not supported yet in `@upstash/redis`.
</Note>

</Accordion>

<Accordion title="upstash_redis" icon="python" iconType="brands">

<Note>
  This command is not supported yet in `upstash_redis`.
</Note>

</Accordion>

<Accordion title="ioredis" icon="node-js" iconType="brands">

```ts
import Redis from "ioredis";

const redis = new Redis(process.env.REDIS_URL!);
const result = await redis.config("SET", "notify-keyspace-events", "Ex");
console.log(result);
```

</Accordion>

<Accordion title="node-redis" icon="node-js" iconType="brands">

```ts
import { createClient } from "redis";

const client = await createClient({ url: process.env.REDIS_URL })
  .on("error", console.error)
  .connect();
const result = await client.configSet("notify-keyspace-events", "Ex");
console.log(result);
```

</Accordion>

<Accordion title="redis-py" icon="python" iconType="brands">

```python
import os
import redis

client = redis.from_url(os.environ["REDIS_URL"])
result = client.config_set("notify-keyspace-events", "Ex")
print(result)
```

</Accordion>

<Accordion title="go-redis" icon="golang" iconType="brands">

```go
package main

import (
    "context"
    "fmt"
    "os"

    "github.com/redis/go-redis/v9"
)

func main() {
    opts, err := redis.ParseURL(os.Getenv("REDIS_URL"))
    if err != nil {
        panic(err)
    }
    client := redis.NewClient(opts)
    result, err := client.ConfigSet(context.Background(), "notify-keyspace-events", "Ex").Result()
    if err != nil {
        panic(err)
    }
    fmt.Println(result)
}
```

</Accordion>

<Accordion title="jedis" icon="java" iconType="brands">

```java
import java.net.URI;

import redis.clients.jedis.Jedis;

try (Jedis jedis = new Jedis(new URI(System.getenv("REDIS_URL")))) {
  Object result = jedis.configSet("notify-keyspace-events", "Ex");
  System.out.println(result);
}
```

</Accordion>

<Accordion title="redis-rs" icon="rust" iconType="brands">

```rust
fn main() -> redis::RedisResult<()> {
    let url = std::env::var("REDIS_URL").expect("REDIS_URL is not set");
    let client = redis::Client::open(url)?;
    let mut connection = client.get_connection()?;

    let mut command = redis::cmd("CONFIG");
    command.arg("SET");
    command.arg("notify-keyspace-events");
    command.arg("Ex");
    let result: redis::Value = command.query(&mut connection)?;
    println!("{result:?}");
    Ok(())
}
```

</Accordion>

</AccordionGroup>
