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
- Use one of the supported schemes: turso://, libsql://, https://, or http:// (http only for testing/local)
- Replace file:// or other scheme with the correct https URL of the sync remote
- Check for typos in the scheme string (htts, httpss, etc.)
- 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
- Store remotes with explicit schemes in config; never accept bare hostnames
- Validate scheme against {turso, libsql, http, https} at configuration load time
- Watch for scheme typos (htts, httpss) in hand-edited config
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
- HTTP request missing URL: no URL in request and no baseUrl i
- The sync remote URL must be absolute.
- Turso batch execution requires a direct remote or embedded r
- Sync Interval must be between 0 and {MaximumSyncIntervalSeco
- Auth Token requires a remote Turso URL Data Source.
AI-assisted analysis of tursodatabase/turso@6c72522679 (2026-08-31).
Data as JSON: /api/errors/22dbc7211d55d989.
Report an issue: GitHub.