zenml login command connects your CLI client to a ZenML server. This works with ZenML Pro, self-hosted servers, or local deployments.
Quick Start
Connect to ZenML Pro
Connect to Remote Server
Start Local Server
Basic Usage
Thezenml login command has context-aware behavior:
When not connected to a server:
- Displays an interactive menu with three options:
- Login to a local server
- Login to ZenML Pro
- Login to a custom cloud server
- Triggers a new web login flow to refresh your session
- Use this when your CLI session expires
Command Options
Server Argument
The optionalSERVER argument can be:
- A URL:
https://zenml.example.com - ZenML Pro server name:
my-company-server - ZenML Pro server UUID:
a1b2c3d4-e5f6-7890-abcd-ef1234567890 - SQL database URL:
mysql://user:pass@host:port/database
Passing a SERVER argument skips the web login flow if your session is still valid. Use
--refresh to force re-authentication.Login Flags
| Flag | Description |
|---|---|
--pro | Login to ZenML Pro regardless of current state |
--refresh | Force a new login flow even if session is valid |
--local | Start and connect to a local server |
--api-key | Authenticate using an API key instead of web login |
--project | Set active project immediately after connecting |
Local Server Options
When using--local, customize the server deployment:
| Option | Type | Description |
|---|---|---|
--blocking | Flag | Run server as a foreground process (blocks CLI until stopped) |
--docker | Flag | Start server as a Docker container instead of local process |
--port | Integer | Custom TCP port for the server (default: 8237) |
--ip-address | IP Address | Listen on a specific IP (default: 127.0.0.1) |
--image | String | Custom Docker image (only with --docker) |
--ngrok-token | String | Ngrok auth token for public URL (useful in Google Colab) |
--restart | Flag | Force restart of existing local server |
Examples
Interactive Login (ZenML Pro)
Connect to Remote Server
Start Local Server (Background)
Start Local Docker Server
Start Local Server on Custom Port
Run Local Server in Foreground
Ctrl+C to stop.
Login with API Key
Login and Set Project
Refresh Existing Session
Expose Local Server with Ngrok
Restart Local Server
Multiple Server Management
The CLI can authenticate to multiple servers simultaneously, though only one is active at a time.List Available Servers
Switch Between Servers
API Key Authentication
API keys provide non-interactive authentication, ideal for CI/CD pipelines.Generate API Key
In the ZenML dashboard:- Go to Settings → API Keys
- Click Generate New Key
- Copy the key (starts with
znml_)
Use API Key in CLI
Use API Key in Environment Variable
Local Server Deployment
Local servers are perfect for development and testing.Process vs Docker
Process Mode (default):- Faster startup
- Uses your local Python environment
- Lightweight
--docker):
- Isolated environment
- Consistent across machines
- Easier to clean up
Custom Docker Image
Accessing Local Server Remotely
By default, local servers only accept connections from127.0.0.1. To allow remote access:
Project Selection
ZenML servers organize resources into projects. After login, you can switch projects:Verifying Connection
Check your connection status:Troubleshooting
Browser Not Opening
If the web login flow doesn’t open your browser:- Manually copy the URL from the terminal
- Paste it into your browser
- Complete authentication
- Return to the terminal
Local Server Won’t Start
Common issues: Port already in use:Session Expired
If your CLI session expires:CI/CD Usage
For automated pipelines, use API key authentication:Next Steps
Check Status
Run
zenml status to verify your connectionConfigure Stack
Set up your MLOps stack after connecting
Manage Projects
Use
zenml project list to see available projectsRun Pipeline
Execute your first pipeline on the server
