Set Active JFrog CLI Server

Switch the active JFrog CLI server with jf config use so commands target a different configured server by default.

The active server is the default target for JFrog CLI commands when you do not pass --server-id or related environment overrides. jf config use switches that default to another configured server ID. The setting is persisted in your CLI configuration file. To create a server configuration first, see Add a JFrog CLI Server Configuration.

This topic covers the following:

Synopsis

jf config use <server-id>

Aliases: jf c use

Where:

  • <server-id>: The configured server ID to make active.

Arguments

The following table lists command arguments.

ArgumentRequiredDescription
server-idYesThe server ID to set as active

Flags

None.

Examples

Set the Active Server

Switch the default server that JFrog CLI commands use when you don't pass --server-id.

To set the active server:

  1. Run the following command:

    jf config use <server-id>

    Where:

    • <server-id>: The server ID to use as the default.

    For example:

    jf config use staging-server

    Expected output:

    [Info] Using server ID 'staging-server' (https://staging-server.jfrog.io/)

    The CLI Platform URL for that server ID is appended in parentheses.

  2. To confirm the change:

    Run the following command:

    jf config show

    You should see staging-server listed as Default: true.

Override the Server for a Single Command or Session

If you only need a different server for 1 command or for the current shell session, you do not have to change the global default.

To override the server for a single command:

  • Run the command with --server-id. The value must be a server ID you configured with jf config add.

    jf rt ping --server-id=<server-id>

    Where:

    • <server-id>: The server ID to use for this invocation only.

    For example:

    jf rt ping --server-id=prod-server

    The --server-id flag takes precedence over both the active server set by jf config use and the JFROG_CLI_SERVER_ID environment variable.

To override the server for the current terminal session:

  1. Export the environment variable:

    export JFROG_CLI_SERVER_ID=<server-id>

    Where:

    • <server-id>: Server ID to use until you close the shell or unset JFROG_CLI_SERVER_ID.

    For example:

    export JFROG_CLI_SERVER_ID=prod-server
  2. Run CLI commands as usual. They use prod-server without changing the active config stored by jf config use:

    jf rt ping

When to Use

Use jf config use when you have multiple server configurations (for example, dev-server, staging-server, prod-server) and want to switch the default for all subsequent commands.

Important Notes

  • The active server setting persists across sessions. It is stored in the configuration file (~/.jfrog/jfrog-cli.conf.v6).
  • Using --server-id on a command always overrides the active server for that command only.
  • The JFROG_CLI_SERVER_ID environment variable overrides the active server for the entire terminal session (until you close the terminal or run unset JFROG_CLI_SERVER_ID).
  • Concurrent sessions: All terminal sessions share the same configuration file. If multiple terminals run jf config use simultaneously, the last write wins and silently overrides earlier changes. For parallel or continuous integration and delivery (CI/CD) workflows, use --server-id or JFROG_CLI_SERVER_ID instead of switching the global active server.
  • Non-existent server ID. If the specified server-id does not exist, JFrog CLI prints [Error] Could not find a server with ID '<server-id>'. and exits with a non-zero exit code. The active server is left unchanged. Confirm the server ID with jf config show before you run jf config use.

Frequently Asked Questions

This section provides answers to frequently asked questions.

plusFAQs
Q: How do I switch the active JFrog CLI server?

A: Run jf config use <server-id> with the ID of a server you already configured. See Set the Active Server for the full example.

Q: What happens if I run jf config use with a server ID that doesn't exist?

A: JFrog CLI prints [Error] Could not find a server with ID '<server-id>'. and exits with a non-zero exit code. The active server is left unchanged.

Q: What's the difference between jf config use and the --server-id flag?

A: jf config use changes the persisted default server for all future commands. --server-id on a single command overrides the active server for that command only, without changing the stored default.

Q: Can I override the active server for just my current terminal session?

A: Yes. Export JFROG_CLI_SERVER_ID=<server-id> in your shell. See Override the Server for a Single Command or Session.

Q: What happens if multiple terminals run jf config use at the same time?

A: All sessions share the same configuration file, so the last write wins and silently overrides earlier changes. For parallel or CI/CD workflows, use --server-id or JFROG_CLI_SERVER_ID instead of switching the global active server.

Related Topics


What’s Next

You're all set. Explore the general commands available in JFrog CLI.

Did this page help you?