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.
| Argument | Required | Description |
|---|---|---|
server-id | Yes | The 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:
-
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-serverExpected output:
[Info] Using server ID 'staging-server' (https://staging-server.jfrog.io/)The CLI Platform URL for that server ID is appended in parentheses.
-
To confirm the change:
Run the following command:
jf config showYou should see
staging-serverlisted asDefault: 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 withjf 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-serverThe
--server-idflag takes precedence over both the active server set byjf config useand theJFROG_CLI_SERVER_IDenvironment variable.
To override the server for the current terminal session:
-
Export the environment variable:
export JFROG_CLI_SERVER_ID=<server-id>Where:
<server-id>: Server ID to use until you close the shell orunset JFROG_CLI_SERVER_ID.
For example:
export JFROG_CLI_SERVER_ID=prod-server -
Run CLI commands as usual. They use
prod-serverwithout changing the active config stored byjf 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-idon a command always overrides the active server for that command only. - The
JFROG_CLI_SERVER_IDenvironment variable overrides the active server for the entire terminal session (until you close the terminal or rununset JFROG_CLI_SERVER_ID). - Concurrent sessions: All terminal sessions share the same configuration file. If multiple terminals run
jf config usesimultaneously, the last write wins and silently overrides earlier changes. For parallel or continuous integration and delivery (CI/CD) workflows, use--server-idorJFROG_CLI_SERVER_IDinstead of switching the global active server. - Non-existent server ID. If the specified
server-iddoes 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 withjf config showbefore you runjf config use.
Frequently Asked Questions
This section provides answers to frequently asked questions.
FAQs
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
Updated 2 days ago
What’s Next
You're all set. Explore the general commands available in JFrog CLI.
