---
title: Run the Diagnostics CLI (nrdiag)
source: https://docs.newrelic.com/docs/new-relic-solutions/solve-common-issues/diagnostics-cli-nrdiag/run-diagnostics-cli-nrdiag
---

[Run the CLI](https://one.newrelic.com/launcher/diagnostics?pane=eyJuZXJkbGV0SWQiOiJkaWFnbm9zdGljcy5jbGktb3V0cHV0IiwgInNob3dJbnN0YWxsUnVuTW9kYWwiOiB0cnVlfQ==)

## Install and run the Diagnostics CLI

The Diagnostics CLI can be installed and run with a single command on Linux and Windows. This installation method will download the Diagnostics CLI binary to the present working directory. The Diagnostics CLI automatically searches its root directory and subdirectories for agent configuration files and other relevant data.

**Linux**

1.  Change directory to the application's root directory.
2.  Execute the following:
    ```shell
    curl -Ls https://download.newrelic.com/nrdiag/scripts/install.sh | bash && sudo ./nrdiag CLI_OPTIONS
    ```
    Recommendation: Scope your troubleshooting with a [task suite](#suites) (`-suites`), and upload relevant files to your New Relic account with the [attachment flag](#automatic) (`-attach`).

**Windows**

1.  Change directory to the application's root directory.
2.  Execute the following:
    ```powershell
    [Net.ServicePointManager]::SecurityProtocol = 'tls12, tls'; (New-Object System.Net.WebClient).DownloadFile("https://download.newrelic.com/nrdiag/scripts/install.ps1", "$env:TEMP\install.ps1"); & PowerShell.exe -ExecutionPolicy Bypass -File $env:TEMP\install.ps1; & '.\nrdiag.exe' CLI_OPTIONS
    ```
    Recommendation: Scope your troubleshooting with a [task suite](#suites) (`-suites`), and upload relevant files to your New Relic account with the [attachment flag](#automatic) (`-attach`).

## Platform-specific manual installation procedures [#platform]

To manually install and run the Diagnostics CLI, follow the procedures for your platform:

**Linux**

1.  Ensure you have the Diagnostics CLI:

    -   From the command line, change the directory to your application's root directory and ensure that the `nrdiag.zip` file is present.

        OR
    -   [Manually download the latest version](https://download.newrelic.com/nrdiag/nrdiag_latest.zip).
2.  Unzip `nrdiag.zip` if necessary.
3.  From the `nrdiag_1.2.3/linux` directory, move `nrdiag` into the application's root directory.
4.  Run `nrdiag` (along with any [CLI options](https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/diagnostics-cli-nrdiag/pass-command-line-options-nrdiag)

    ```shell
    ./nrdiag CLI_OPTIONS
    ```

    The Diagnostics CLI outputs any issues it discovers, and uploads relevant files to your New Relic account if you include the `-attach` flag.

**Windows**

1.  Ensure you have the Diagnostics CLI:

    -   From the command line, change directory to the application's root directory, and ensure that the `nrdiag.zip` file is present.

        OR
    -   [Manually download the latest version](https://download.newrelic.com/nrdiag/nrdiag_latest.zip).
2.  Unzip `nrdiag.zip` if necessary.
3.  From the `nrdiag_1.2.3/win` directory, move `nrdiag.exe` or `nrdiag_x64.exe` into the application's root directory.
4.  For troubleshooting web applications, ensure you are running the executable from your project's **parent** directory, or specify your config file location with the `-c` option.
5.  Run the executable (along with any [CLI options](https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/diagnostics-cli-nrdiag/pass-command-line-options-nrdiag) from the directory you placed the binary. Since some checks require elevated permissions, for best results run from an admin shell.

    Run via PowerShell if you add any `CLI_OPTIONS`:

    ```shell
    ./nrdiag.exe CLI_OPTIONS
    ```

    **OR**, for x64 systems:

    ```shell
    ./nrdiag_x64.exe CLI_OPTIONS
    ```

    The Diagnostics CLI outputs any issues it discovers, and uploads relevant files to New Relic account if you include the `-attach` flag.

**macOS**

1.  Ensure you have the Diagnostics CLI:

    -   From the command line, change directory to the application's root directory and ensure that the `nrdiag.zip` file is present.

        OR
    -   [Manually download the latest version](https://download.newrelic.com/nrdiag/nrdiag_latest.zip).
2.  Unzip `nrdiag.zip` if necessary.
3.  From the `nrdiag_1.2.3/mac` directory, move `nrdiag` into the application's root directory.
4.  Run `nrdiag` (along with any [CLI options](https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/diagnostics-cli-nrdiag/pass-command-line-options-nrdiag)

    ```shell
    ./nrdiag CLI_OPTIONS
    ```

    The Diagnostics CLI outputs any issues it discovers and uploads relevant files to your New Relic account if you include the `-attach` flag.

**Browser monitoring**

1.  Ensure you have the latest version of the Diagnostics CLI. If necessary, [manually download the latest version](https://download.newrelic.com/nrdiag/nrdiag_latest.zip).
2.  Unzip `nrdiag.zip` if necessary.
3.  From the `nrdiag_1.2.3/`OS directory, run `nrdiag` (along with any [CLI options](https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/diagnostics-cli-nrdiag/pass-command-line-options-nrdiag):

    ```shell
    ./nrdiag -browser-url WEBSITE_URL CLI_OPTIONS
    ```

    The Diagnostics CLI outputs any issues it discovers and uploads relevant files to your New Relic account if you include the `-attach` flag.

**Docker container**

To troubleshoot your New Relic-instrumented application running in a Docker container, use the `docker exec` command:

1.  [Download](https://download.newrelic.com/nrdiag/nrdiag_latest.zip) and unzip the `nrdiag_latest.zip` file.
2.  Copy the binary to the container. Replace `IMAGE_NAME` with the name of your docker container:

    ```shell
    docker cp nrdiag/linux/nrdiag IMAGE_NAME:/bin
    ```
3.  Run the `nrdiag` command in the docker container. Replace `IMAGE_NAME` as above, and replace `APPLICATION_ROOT` with the root directory of your application, where you installed the New Relic agent:

    ```shell
    docker exec -it -w APPLICATION_ROOT IMAGE_NAME nrdiag
    ```
4.  (Optional) Remove the `nrdiag` binary when finished:

    ```shell
    docker exec IMAGE_NAME rm /bin/nrdiag
    ```

## Suites flag (highly recommended CLI option) [#suites]

A suite is a collection of health checks that target specific products or issues. Using a suite can help narrow the scope of troubleshooting and reduce the occurrence of false positives.

To review a list of available suites, run the Diagnostics CLI with the `-help suites` option:

```shell
./nrdiag -help suites
```

To run suites with `nrdiag`, provide the `-suites` flag and one or more suite names (for example, `java`) to run as arguments.

**Linux and macOS:**

-   For 64-bit systems:

    ```shell
    ./nrdiag_x64 -suites SUITE NAMES
    ```
-   For ARM64 systems:

    ```shell
    ./nrdiag_arm64 -suites SUITE NAMES
    ```

**Windows:**

To run from PowerShell, add `./` to the start of `cmd`.

-   For 32-bit systems:

    ```shell
    nrdiag.exe -suites SUITE NAMES
    ```
-   For 64-bit systems:

    ```shell
    nrdiag_x64.exe -suites SUITE NAMES
    ```
-   For ARM64 systems:

    ```shell
    nrdiag_arm64.exe -suites SUITE NAMES
    ```

## Scripts [#scripts]

Scripts provide an additional datasource for information that isn't collected by a task. The catalog of available scripts can be found in [the Diagnostic CLI's github repository](https://github.com/newrelic/newrelic-diagnostics-cli/tree/main/scriptcatalog).

### Script output

Script output is printed to the screen and is saved in a file based on the name of the script (for example, `name-of-script.out`). This is saved in the directory specified by `-output-path`, defaulting to the current directory.

Scripts can also output files, either to the current working directory or the directory specified by `-output-path`. All output files are included in the results zip in the `ScriptOutput/` directory.

### Script results

The results of running a script can be found in the `nrdiag-output.json` file with the following schema:

```json
"Script": {
  "Name": "example",
  "Description": "Example Description",
  "Output": "example output",
  "OutputFiles": [
    "/path/to/example.out",
    "/path/to/another-file.out"
  ],
  "OutputTruncated": false
}
```

The `Output` field contains the stdout output. If it is over 20000 characters, it is truncated and the `OutputTruncated` field is set to `true`. Even if trucated, the full output is still available in the `ScriptOutput/` directory in the zip file.

A list of files the script created can be found in the `Outputfiles` field.

### List, view, and run a script [#list-view-run-script]

**List available scripts**

To view a list of the scripts available to run, use `-list-scripts`:

````shell
./nrdiag -list-scripts
```

````

**View a script**

To view a script without running it:

````shell
./nrdiag -script SCRIPT_NAME
```

````

**Run a script**

To run a script:

````shell
./nrdiag -script SCRIPT_NAME -run
```

````

**Run a script with arguments**

To run a script with arguments:

````shell
./nrdiag -script SCRIPT_NAME -run -script-flags "-foo bar"
```

````

**Run a script along with suites**

To run a script and suites at the same time:

````shell
./nrdiag -script SCRIPT_NAME -run -s SUITE NAMES"
```

````

## Include additional files in the zip [#include-additional-files]

If you have additional files that you would like to share with support, you can include them in the `nrdiag-output.zip` file using the `-include` command line flag. This can be used with a single file or a directory. If a directory is provided, all of its subdirectories are included. The total size limit of the files included is 4GB.

Use this in combination with `-attach` to [upload the files](#attach-account-results) to your New Relic account.

**Linux and macOS:**

-   For 64-bit systems:

    ```shell
    ./nrdiag_x64 -include /entire/directory/ -attach
    ```
-   For ARM64 systems:

    ```shell
    ./nrdiag_arm64 -include /entire/directory/ -attach
    ```

**Windows:**

To run from PowerShell, add `./` to the start of `cmd`.

-   For 32-bit systems:

    ```shell
    nrdiag.exe -include Path\To\File -attach
    ```

-   For 64-bit systems:

    ```shell
    nrdiag_x64.exe -include \Entire\Directory\ -attach
    ```

-   For ARM64 systems:

    ```shell
    nrdiag_arm64.exe -include \Entire\Directory\ -attach
    ```

## Upload results to a New Relic account [#attach-account-results]

> #### ⚠️ IMPORTANT
>
> If your system is **not** configured to connect to external IP addresses, this method will not work. Instead, attach the [output files](https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/diagnostics-cli-nrdiag/interpret-nrdiag-output) in an email to New Relic Support.

### Automatic account upload [#automatic]

To upload your results automatically to a New Relic account when the Diagnostics CLI is executed, use either the `-attach` or `-api-key` command line flags. The `-attach` flag will validate any New Relic license keys found in your environment and upload the run to the account associated with the license key. Alternatively, the `-api-key` flag will use the user key provided to upload the run, regardless of the presence of a valid license key.

Uploading your results to an account will automatically upload the contents of the `nrdiag-output.json` and `nrdiag-output.zip`.

**Linux and macOS**

-   For 64-bit systems:

    ```shell
    ./nrdiag_x64 -attach
    ```

    OR

    ```shell
    ./nrdiag_x64 -api-key ${API_KEY}
    ```
-   For ARM64 systems:

    ```shell
    ./nrdiag_arm64 -attach
    ```

    OR

    ```shell
    ./nrdiag_arm64 -api-key ${API_KEY}
    ```

**Windows**

To run from PowerShell, add `./` to the start of `cmd`.

-   For 32-bit systems:

    ```shell
    nrdiag.exe -attach
    ```

    OR

    ```shell
    nrdiag.exe -api-key ${API_KEY}
    ```
-   For 64-bit systems:

    ```shell
    nrdiag_x64.exe -attach
    ```

    OR

    ```shell
    nrdiag_x64.exe -api-key ${API_KEY}
    ```
-   For ARM64 systems:

    ```shell
    nrdiag_arm64.exe -attach
    ```

    OR

    ```shell
    nrdiag_arm64.exe -api-key ${API_KEY}
    ```

### Region Selection [#region]

By default, the Diagnostics CLI uploads results to New Relic accounts hosted in the US data center. If your account is hosted in the EU or Japan data center, add `-region eu` or `-region jp` to the command.

```shell
./nrdiag -region eu ...
```

```shell
./nrdiag -region jp ...
```
