tursodatabase/turso · error · InvalidOperationException

Data Source is not a remote Turso URL: {DataSource}

Error message

Data Source is not a remote Turso URL: {DataSource}

What it means

Thrown by TursoConnectionOptions.GetRemoteUri() when the 'Data Source' value is not an absolute URI with one of the accepted remote schemes (libsql, http, https, ws, wss). The provider needs a full absolute URL to build the HTTP endpoint for a remote Turso database; local file paths, relative strings, empty values, or other schemes cannot be resolved to a remote endpoint. The message echoes the offending Data Source value so you can see exactly what was parsed.

Source

Thrown at bindings/dotnet/src/Turso.Data/TursoConnectionOptions.cs:63

                    nameof(SyncInterval),
                    value,
                    $"Sync Interval must be between 0 and {MaximumSyncIntervalSeconds} seconds.");
            }

            return value;
        }
    }

    public string SyncClientName => _builder.SyncClientName;

    public int SyncLongPollTimeout => _builder.SyncLongPollTimeout;

    public bool BootstrapIfEmpty => _builder.BootstrapIfEmpty;

    public int PartialBootstrapPrefix => _builder.PartialBootstrapPrefix;

    public string PartialBootstrapQuery => _builder.PartialBootstrapQuery;

    public long PartialSyncSegmentSize => _builder.PartialSyncSegmentSize;

    public bool PartialSyncPrefetch => _builder.PartialSyncPrefetch;

    public string RemoteEncryptionCipher => _builder.RemoteEncryptionCipher;

    public string RemoteEncryptionKey => _builder.RemoteEncryptionKey;

    public long PushOperationsThreshold => _builder.PushOperationsThreshold;

    public long PullBytesThreshold => _builder.PullBytesThreshold;

    public bool ForceLogicalMvccPull => _builder.ForceLogicalMvccPull;

    public string SyncExperimentalFeatures => _builder.SyncExperimentalFeatures;

    public bool? Tls => _builder.Tls;

View on GitHub (pinned to 6c72522679)

Solutions

  1. Set Data Source to an absolute remote URL with an allowed scheme, e.g. 'Data Source=libsql://my-db-my-org.turso.io'.
  2. If you meant a local database, keep a plain file path and do not use remote/replica features (IsReplica, remote sync paths) with it.
  3. Fix malformed URLs: include '://' (e.g. 'libsql://' not 'libsql:'), and trim stray whitespace or quotes around the value from config/env vars.
  4. Confirm the scheme is exactly one of libsql, http, https, ws, wss.

Example fix

// before
Data Source=app.db   // local path, but the code path calls GetRemoteUri()/replica sync

// after
Data Source=libsql://my-db-my-org.turso.io;Auth Token=eyJhbGciOi...
Defensive patterns

Strategy: validation

Validate before calling

var options = new TursoConnectionOptions(builder);
if (!options.IsRemote || !Uri.TryCreate(options.DataSource, UriKind.Absolute, out _))
    throw new ConfigurationException($"Data Source must be a remote libsql/http(s)/ws(s) URL, got: {options.DataSource}");
await conn.OpenAsync(ct);

Type guard

static bool IsRemoteTursoUrl(string dataSource) =>
    Uri.TryCreate(dataSource, UriKind.Absolute, out var uri)
    && uri.Scheme is "libsql" or "http" or "https" or "ws" or "wss";

Try / catch

try { await conn.OpenAsync(ct); } catch (InvalidOperationException ex) when (ex.Message.Contains("not a remote Turso URL")) { /* fail fast with config error, do not retry */ }

Prevention

When it happens

Trigger: Calling TursoConnection.Open() (or any remote/replica code path that calls GetRemoteUri()) with Data Source set to a local path like 'app.db' or 'file:app.db', an empty string, a relative URL, a value with surrounding whitespace or quotes, or a scheme outside the allowed set such as 'sqlite://host' or 'libsql-db://host'.

Common situations: Copying a Microsoft.Data.Sqlite connection string into a Turso connection; switching a project from a local file database to Turso Cloud without updating Data Source; typos like 'libsql//host' or a missing '://' so the URI is not absolute; per-environment config where one environment points at a local file but the code path assumes remote.

Related errors


AI-assisted analysis of tursodatabase/turso@6c72522679 (2026-08-20). Data as JSON: /api/errors/ea5ddaffbf687e94. Report an issue: GitHub.