tursodatabase/turso · error · InvalidOperationException

Unsupported sync URL scheme: {uri.Scheme}

Error message

Unsupported sync URL scheme: {uri.Scheme}

What it means

When normalizing the remote URI, TursoSyncDatabase maps known schemes (turso, libsql -> https; http -> http; https -> https). Any other scheme is rejected with this InvalidOperationException because the sync transport only knows how to speak HTTP(S).

Source

Thrown at bindings/dotnet/src/Turso.Data/TursoSyncDatabase.cs:785

                "Auth Token requires HTTPS sync requests unless the host is localhost or loopback.");
        }
    }

    private static bool HasSameOrigin(Uri left, Uri right)
    {
        return left.Scheme.Equals(right.Scheme, StringComparison.OrdinalIgnoreCase)
               && left.IdnHost.Equals(right.IdnHost, StringComparison.OrdinalIgnoreCase)
               && left.Port == right.Port;
    }

    private static Uri NormalizeRemoteUri(Uri uri)
    {
        var scheme = uri.Scheme.ToLowerInvariant() switch
        {
            "turso" or "libsql" => Uri.UriSchemeHttps,
            "http" => Uri.UriSchemeHttp,
            "https" => Uri.UriSchemeHttps,
            _ => throw new InvalidOperationException($"Unsupported sync URL scheme: {uri.Scheme}"),
        };
        return new UriBuilder(uri)
        {
            Scheme = scheme,
            Port = uri.IsDefaultPort ? -1 : uri.Port,
            UserName = string.Empty,
            Password = string.Empty,
        }.Uri;
    }

    private static Uri CombineUri(Uri baseUri, string path)
    {
        var baseText = baseUri.GetLeftPart(UriPartial.Path).TrimEnd('/');
        return new Uri(baseText + "/" + path.TrimStart('/'), UriKind.Absolute);
    }

    internal static TursoSyncDatabaseConfiguration CreateNativeConfiguration(
        TursoSyncDatabaseOptions options,

View on GitHub (pinned to 6c72522679)

Solutions

  1. Use one of the supported schemes: turso://, libsql://, https://, or http:// (http only for testing/local)
  2. Replace file:// or other scheme with the correct https URL of the sync remote
  3. Check for typos in the scheme string (htts, httpss, etc.)
  4. Validate the URI with Uri.TryCreate and check the scheme before constructing options

Example fix

// before
var options = new TursoSyncDatabaseOptions(path, new Uri("postgres://db.example.com/mydb"));
// after
var options = new TursoSyncDatabaseOptions(path, new Uri("https://db.example.com"));
Defensive patterns

Strategy: validation

Validate before calling

bool TryNormalizeRemote(string url, out Uri normalized)
{
    normalized = null!;
    if (!Uri.TryCreate(url, UriKind.Absolute, out var uri)) return false;
    return uri.Scheme is "turso" or "libsql" or "http" or "https" && (normalized = uri) is not null;
}
// if (!TryNormalizeRemote(configValue, out var remote)) throw new ArgumentException($"Unsupported sync URL scheme in '{configValue}'");

Try / catch

try
{
    var db = new TursoSyncDatabase(options);
}
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Unsupported sync URL scheme"))
{
    logger.LogError(ex, "Remote URI scheme is not supported; use turso://, libsql://, https:// or http://");
    throw;
}

Prevention

When it happens

Trigger: Constructing TursoSyncDatabase with a remote URI whose scheme is not one of turso, libsql, http, or https, e.g. file:///path/to/db, ws://host, postgres://host, or a misspelled scheme like htts://host.

Common situations: Copy-pasting a file:// path as the remote; typos in the scheme; reusing a connection string intended for another driver (postgres://, mysql://); shell variable interpolation leaving a malformed URL.

Related errors


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