> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lerian.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# Test a Data Source Connection

> Verify that a Data Source's credentials and network settings are correct before relying on it for report generation.

Use this page to confirm that Reporter can reach a Data Source and load its schema. The Data Source can be an internal connection already configured for a Lerian product or an external database connection added from the Console.

## Objective

***

Validate connectivity before operators rely on the Data Source in Templates or Reports.

For example, test after creating `production-postgres`, after a password rotation, or before generating a monthly report that depends on a recently changed schema.

## When to use

***

Use this task:

* immediately after adding an external Data Source;
* when checking an existing internal Data Source before using it in a Template or filter;
* after editing host, credentials, schema, or SSL settings;
* before generating Reports that depend on the connection;
* when no tables appear in the schema browser;
* when Report generation fails because of connection or schema errors.

## Before you start

***

Confirm:

* the Data Source exists on the **Data Sources** page;
* the expected host, port, database name, username, schema, and SSL settings are configured;
* the database should be reachable from Reporter;
* the database user has permission to read the required tables.

<Note>
  A successful test confirms access at that moment. It does not guarantee future Reports will succeed if credentials, network rules, or database permissions change later.
</Note>

## Step by step

***

<Steps>
  <Step title="Open Data Sources">
    Go to **Data Sources**.
  </Step>

  <Step title="Find the connection">
    Locate the card for the Data Source you need to test.
  </Step>

  <Step title="Run the test">
    Click **Test Connection**.
  </Step>

  <Step title="Wait for the result">
    The status changes to **Connecting** while Reporter tests the connection.
  </Step>

  <Step title="Read the result">
    If the test succeeds, the status changes to **Connected** and latency is displayed, such as `Latency: 45ms`. If it fails, the status changes to **Disconnected** and an error message appears.
  </Step>

  <Step title="Check schema when connected">
    Expand the connection card to view the schemas, tables, and fields returned for the connection.
  </Step>
</Steps>

## Field guide

***

### Test action and result fields

| Field or status     | What it means                                                                                                                     | Example                                         |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
| **Test Connection** | Action on the Data Source card. The Console uses the selected `connectionId` to call the test endpoint.                           | Test `production-postgres`.                     |
| **Connecting**      | Local status while the test request is pending. Wait for the final result before editing or generating a Report.                  | **Connecting**                                  |
| **Connected**       | Successful result. Reporter returned `connected` or `success`, and the Data Source is usable at that moment.                      | **Connected** with `Latency: 45ms`.             |
| **Disconnected**    | Failed result or request error. Check host, port, credentials, network access, schema, and SSL settings.                          | **Disconnected** after `authentication failed`. |
| Latency             | `latencyMs`, returned in milliseconds after a successful test. It is a signal, not a guarantee of future Report generation speed. | `45`                                            |
| Test message        | `message` returned by Reporter, usually most useful on failure. Use it as the first clue for what to fix.                         | `authentication failed`                         |

### Schema fields shown after testing

| Schema item      | What it shows                                                                                                                    | Example                |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------- |
| Tables           | `tables[].name` returned by schema validation. These are the tables operators can use in Template Builder and report filters.    | `transactions`         |
| Fields           | `tables[].fields[]` inside each table. These fields can be inserted as Template variables or used as Report filters.             | `amount`, `created_at` |
| No schema loaded | Empty `tables` array or schema load error. The connection may work, but table permissions or schema names still need correction. | No tables discovered.  |

## Expected result

***

The Data Source status is **Connected**, schema information is available, and operators can safely use its fields in Template Builder and report filters.

## Common errors and care points

***

<AccordionGroup>
  <Accordion title="Connection succeeds but no tables appear">
    Check schema names and database permissions. The database user may connect but not have access to the tables needed for reporting.
  </Accordion>

  <Accordion title="Connection fails after editing credentials">
    Reopen the Data Source and confirm username, password, host, port, and SSL settings.
  </Accordion>

  <Accordion title="Testing once and assuming it stays valid">
    Network rules, rotated passwords, and database permissions can change. Re-test when generation errors appear.
  </Accordion>
</AccordionGroup>

## Next steps

***

* Use [Template Builder](/en/lerian-console/reporter-console/template-builder) after schemas and fields are visible.
* Use [Generate a Report](/en/lerian-console/reporter-console/generating-a-report) after the Data Source is healthy.
* Use [Edit a Data Source](/en/lerian-console/reporter-console/editing-a-data-source) if the test fails because settings are wrong.

<CardGroup cols={2}>
  <Card title="Test connection" icon="code" href="/en/reference/reporter/connections/test-connection">
    Test a Data Source connection programmatically.
  </Card>

  <Card title="Validate schema" icon="code" href="/en/reference/reporter/connections/validate-schema">
    Validate schema access for tables and fields.
  </Card>
</CardGroup>
