Skip to main content
Version: 23.1

Broker and Admin API Addresses

In order for rpk to know where to run Kafka-related commands or admin-related commands, you must provide the broker addresses or admin server addresses for each node of a Redpanda cluster. You can specify these addresses as IP addresses or as hostnames, using any of these methods:

  • Command line flag (--brokers or --api-urls)
  • Environment variable setting (REDPANDA_BROKERS or REDPANDA_API_ADMIN_ADDRS)
  • Configuration file setting in redpanda.yaml (rpk.kafka_api.brokers or rpk.admin_api.addresses)

Command line flag settings take precedence over environment variable settings and configuration file settings. If the command line does not contain the --brokers or –-api-urls settings, the environment variable settings are used. If the environment variables are not set, the values in the configuration file are used.

Command line flags

To determine whether a command needs the --brokers flag or the --api-urls flag, follow these guidelines:

The following table shows which rpk commands require the –-brokers flag, which require the –-api-urls or –-hosts flag, and which don’t require either flag.

CommandAddress flag required
rpk acl (all except rpk acl user)--brokers
rpk acl user--api-urls
rpk cloudNone
rpk cluster (all except rpk cluster info and rpk cluster metadata)--api-urls
rpk cluster info--brokers
rpk cluster metadata--brokers
rpk containerNone
rpk debugNone
rpk generateNone
rpk group--brokers
rpk iotuneNone
rpk pluginNone
rpk redpanda (all except rpk redpanda admin)None
rpk redpanda admin--hosts
rpk topic--brokers
rpk versionNone

Environment variable settings

Environment variable settings last for the duration of the shell session, or until you set the variable to a different setting.

You can configure the environment variable REDPANDA_BROKERS for broker addresses so you don’t have to include the --brokers flag each time you run an rpk command. For example, this is how you could configure three brokers on a single machine running on localhost:

export REDPANDA_BROKERS="127.0.0.1:41457,127.0.0.1:39397,127.0.0.1:37735"

For Admin API addresses, configure the environment variable REDPANDA_API_ADMIN_ADDRS. For example, this is how you could configure the addresses to use when running Admin API commands on an external cluster with three nodes:

export REDPANDA_API_ADMIN_ADDRS="192.168.78.34:9644,192.168.78.35:9644,192.168.78.36:9644"

Configuration file settings

As each Redpanda node starts up, a redpanda.yaml configuration file is automatically generated for that node. This file contains a section for rpk settings, which includes Kafka API settings and Admin API settings.

The kafka_api section contains the address and port for each broker. The default address is 0.0.0.0, and the default port is 9092. You can edit this line and replace it with the IP addresses of your Redpanda brokers.

The admin_api section contains the address and port for each admin server. The default address is 0.0.0.0, and the default port is 9644. You can edit this line and replace it with the Admin API IP addresses.

The following example shows the addresses and port numbers for two brokers and two admin servers.

rpk:
kafka_api:
brokers:
- 192.168.72.34:9092
- 192.168.72.35:9092

admin_api:
- 192.168.72.34:9644
- 192.168.72.35:9644
important

If you do not update the default addresses in the redpanda.yaml file, you must provide the required addresses on the command line or by setting the corresponding environment variable.

What do you like about this doc?




Optional: Share your email address if we can contact you about your feedback.

Let us know what we do well: