# CONFIG REWRITE

> Write the running configuration back to the config file the server was started with.

URL: https://docs.hotkv.com/commands/config-rewrite/

```
CONFIG REWRITE
```

- Group: Server
- HotKV Cloud: all plans
- On-Premise: no license needed

`CONFIG REWRITE` saves the settings changed with
[CONFIG SET](https://docs.hotkv.com/commands/config-set/index.md) to the config file the server was started
with, so they survive a restart. Only settings whose running value differs
from what the file says are written. Lines the server does not recognise,
and the rest of the file, are left as they are.

Both config file formats work: a Redis-style `.conf` file and a `.toml`
file. A TOML file is checked before it is written, and left unchanged if the
result would not parse.

## Return value

| Case | Reply (RESP2 and RESP3) |
| --- | --- |
| File written | Simple string `OK` |
| Server started without a config file | Error `ERR The server is running without a config file` |
| File could not be written | Error `ERR Rewriting config file failed, check server logs` |

## Examples

```
127.0.0.1:6379> CONFIG SET slowlog-log-slower-than 5000
OK
127.0.0.1:6379> CONFIG REWRITE
OK
```

In HotKV Cloud, the CLI tab of the panel does not run `CONFIG REWRITE`. Run
it from your own client connection.

## Compatibility

Same replies as Redis 7 and Valkey 8. Redis rewrites only `.conf` files;
HotKV also rewrites TOML config files.

## See also

[CONFIG SET](https://docs.hotkv.com/commands/config-set/index.md), [CONFIG GET](https://docs.hotkv.com/commands/config-get/index.md),
[configuration](https://docs.hotkv.com/operate/configuration/index.md)