Budibase/budibase · error

Unable to connect - ${error}

Error message

Unable to connect - ${error}

What it means

datasources.create first checks connectivity with checkDatasourceValidity using the integration's verification logic. If the datasource cannot connect (valid === false) it throws 'Unable to connect - <error>', where error is the underlying reason (host unreachable, auth failed, bad URL, etc.). No datasource is created on failure.

Source

Thrown at packages/builder/src/stores/builder/datasources.ts:248

    const datasource: Datasource = {
      type: "datasource",
      source: integration.name as SourceName,
      config,
      name: `${name || integration.friendlyName}${nameModifier}`,
      projectIds,
      plus: integration.plus && integration.name !== SourceName.REST,
      isSQL: integration.isSQL,
      ...(restTemplateId && { restTemplateId }),
      ...(restTemplateVersion && { restTemplateVersion }),
    }

    const { valid, error } = await this.checkDatasourceValidity(
      integration,
      datasource
    )
    if (!valid) {
      throw new Error(`Unable to connect - ${error}`)
    }

    const response = await API.createDatasource({
      datasource,
      fetchSchema: integration.plus,
    })

    return this.updateDatasourceInStore(response, { ignoreErrors: true })
  }

  async save({
    integration,
    datasource,
    skipConnectionCheck,
  }: {
    integration: Integration
    datasource: Datasource
    skipConnectionCheck?: boolean

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Read the appended <error> detail and fix the connection config (host, port, user, password, database).
  2. Verify the database is running and reachable from the Budibase server/worker (not just your machine).
  3. Test credentials with a direct client (psql/mysql client) from the server host.
  4. Check TLS/SSL settings if the database enforces encrypted connections.

Example fix

// before
{ config: { host: "localhost", port: 5432 } } // server-side cannot reach localhost
// after
{ config: { host: "postgres.internal", port: 5432, user: "bb", password: "...", database: "app" } }
Defensive patterns

Strategy: validation

Validate before calling

// validate config fields before calling create
const { valid, error } = await datasourceStore.checkDatasourceValidity(integration, datasource)
if (!valid) {
  showConnectionErrorDialog(error)
  return
}

Type guard

const hasConnectionConfig = (d: Datasource): d is Datasource & { config: { host: string; port: number } } =>
  !!d.config && typeof (d.config as { host?: string }).host === "string" && typeof (d.config as { port?: number }).port === "number"

Try / catch

try {
  await datasourceStore.create(datasource)
} catch (e) {
  if (e.message.startsWith("Unable to connect")) {
    showConnectionTroubleshooter(e.message.replace("Unable to connect - ", ""))
    return
  }
  throw e
}

Prevention

When it happens

Trigger: Creating a datasource whose target database rejects/ fails the connectivity check — wrong host/port, database down, invalid credentials, bad connection string, or network/firewall blocking the server-side connection.

Common situations: Typo'd host or port; SSL/TLS requirements not met; DB only reachable from certain networks; expired credentials; Docker networking where 'localhost' points at the wrong container.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/3e1a4741b4620842. Report an issue: GitHub.