Skip to main content

Troubleshoot Contrast CLI

If a Contrast CLI command doesn’t work, find the symptom below and follow the recommended resolution.

All platforms

Issue

Resolution

Sign-in stops with an error about port 41000.

The browser returns to 127.0.0.1 on port 41000, and the CLI can’t use a different port. If the error says another program is using the port, or says the address is already in use, close that program and run contrast-cli configure again.

The CLI says your stored credentials are corrupted.

Run contrast-cli sign-out and then contrast-cli configure.

The CLI says Docker isn’t installed or isn’t on PATH.

Install Docker, or add it to your PATH, and run the command again. This applies to agent enable, agent disable, and demo commands.

The CLI says the Docker daemon could not be reached.

Start Docker Desktop or the Docker Engine service and run the command again.

You connect to the machine over SSH.

If sign-in doesn’t finish, disconnect and reconnect with port forwarding, then run contrast-cli configure, and open the sign-in URL in a browser on your own computer:

ssh -L 41000:127.0.0.1:41000 <host>

On Windows

Issue

Resolution

PowerShell says contrast-cli is not recognized.

A PowerShell window keeps the PATH it started with, so it can’t find a CLI installed after it opened. Run the following command to refresh the PATH in your current window, or open a new PowerShell window:

$env:Path = [Environment]::GetEnvironmentVariable('Path','User') + ';' + [Environment]::GetEnvironmentVariable('Path','Machine')

Sign-in stops and says port 41000 is reserved by Windows or held by a program.

Sign-in needs port 41000 and the CLI can’t use a different one. Closing an app may not help, so find out which case you have:

  1. Run the following command in PowerShell:

    netsh interface ipv4 show excludedportrange protocol=tcp

    If 41000 is not in any listed range, another program holds the port. Find it by running netstat -ano | findstr :41000, close that program, and run contrast-cli configure again.

  2. If 41000 is in a listed range, Windows reserved the port, often for Hyper-V or Docker Desktop. Open PowerShell as an administrator and run net stop winnat, and then net start winnat. Restarting your computer also works. Then run contrast-cli configure again.

  3. To keep this from happening again, an administrator can reserve the port while it is free with the following command:

    netsh int ipv4 add excludedportrange protocol=tcp startport=41000 numberofports=1

    Stopping winnat may briefly interrupt networking for Hyper-V, WSL and Docker Desktop, so restart Docker Desktop.

The CLI says it cannot open your saved sign-in.

Windows can only decrypt your saved sign-in in a session where you signed in with your password, so this happens over SSH with key authentication.

Run the CLI from a desktop session, or connect over SSH with a password.

If it happens in a desktop session, for example after an administrator reset your Windows password, run contrast-cli sign-out and then contrast-cli configure.

In WSL

Issue

Resolution

demo, agent enable, or agent disable CLI commands say the Docker daemon could not be reached.

Turn on Docker Desktop’s WSL integration for your distribution. In Docker Desktop, open Settings, go to Resources, select WSL integration, and turn on your distribution. Then run the CLI command again.

The sign-in page doesn’t open.

Copy the sign-in URL that the CLI prints and paste it into a browser on Windows.