To stop a CockroachDB node running in the background, run the cockroach quit command with appropriate flags. To stop a node running in the foreground, use CTRL + C or run cockroach quit from another shell.

The quit command allows in-flight requests to complete and then shuts down the node. Once a node has been offline for approximately 5 minutes, CockroachDB automatically rebalances replicas from the missing node, using unaffected replicas on other nodes as sources.

Synopsis

# Stop a node:
$ cockroach quit <flags>

# View help:
$ cockroach quit --help

Flags

The quit command supports the following general-use and logging flags.

General

Flag Description
--certs-dir The path to the certificate directory. The directory must contain valid certificates if running in secure mode.

Env Variable: COCKROACH_CERTS_DIR
Default: ${HOME}/.cockroach-certs/
--host The server host to connect to. This can be the address of any node in the cluster.

Env Variable: COCKROACH_HOST
Default:localhost
--insecure Run in insecure mode. If this flag is not set, the --certs-dir flag must point to valid certificates.

Env Variable: COCKROACH_INSECURE
Default: false
--port The server port to connect to.

Env Variable: COCKROACH_PORT
Default: 26257

Logging

By default, the quit command logs errors to stderr.

If you need to troubleshoot this command’s behavior, you can change its logging behavior.

Example

Shut down a node

# Insecure:
$ cockroach quit --insecure --host=nodehostname.com --port=26258

# Secure:
$ cockroach quit --certs-dir=certs --host=nodehostname.com --port=26258

See Also

Other Cockroach Commands



Yes No