tursodatabase/turso · error · InvalidOperationException
Remote Turso URLs must include a host.
Error message
Remote Turso URLs must include a host.
What it means
GetRemoteUri() requires the remote URL to have a host component; this exception means the URI parsed successfully with an accepted scheme but Uri.Host is empty. It typically happens when the '//' authority separator is missing, so .NET parses the URL mailto-style (scheme:value) with no host.
Source
Thrown at bindings/dotnet/src/Turso.Data/TursoConnectionOptions.cs:138
return new TursoRemoteEncryptionOptions
{
Cipher = TursoRemoteEncryptionOptions.ParseCipher(cipher),
Key = key,
};
}
public Uri GetRemoteUri()
{
if (!Uri.TryCreate(DataSource, UriKind.Absolute, out var uri) || !IsRemoteScheme(uri.Scheme))
throw new InvalidOperationException($"Data Source is not a remote Turso URL: {DataSource}");
if (!string.IsNullOrEmpty(uri.Query) || !string.IsNullOrEmpty(uri.Fragment))
throw new InvalidOperationException("Remote Turso URLs must not include query strings or fragments.");
if (!string.IsNullOrEmpty(uri.UserInfo))
throw new InvalidOperationException("Remote Turso URLs must not include embedded user information; use Auth Token instead.");
if (string.IsNullOrEmpty(uri.Host))
throw new InvalidOperationException("Remote Turso URLs must include a host.");
var scheme = uri.Scheme.ToLowerInvariant() switch
{
"libsql" => Tls == false ? "http" : "https",
"turso" => ValidateTls(uri.Scheme, expectedTls: true, normalizedScheme: "https"),
"http" => ValidateTls(uri.Scheme, expectedTls: false),
"https" => ValidateTls(uri.Scheme, expectedTls: true),
"ws" => ValidateTls(uri.Scheme, expectedTls: false, normalizedScheme: "http"),
"wss" => ValidateTls(uri.Scheme, expectedTls: true, normalizedScheme: "https"),
_ => throw new InvalidOperationException($"Unsupported remote Turso URL scheme: {uri.Scheme}")
};
var builder = new UriBuilder(uri)
{
Scheme = scheme,
Port = uri.IsDefaultPort ? -1 : uri.Port,
UserName = string.Empty,
Password = string.Empty,View on GitHub (pinned to 6c72522679)
Solutions
- Write the URL with the authority separator and a real host: 'libsql://my-db-my-org.turso.io'.
- Check that config interpolation actually fills in the host value in every environment.
- If you intended a local file, use a plain path without a remote scheme.
Example fix
// before Data Source=libsql:my-db // after Data Source=libsql://my-db-my-org.turso.io
Defensive patterns
Strategy: validation
Validate before calling
if (!Uri.TryCreate(dataSource, UriKind.Absolute, out var uri) || string.IsNullOrEmpty(uri.Host))
throw new ConfigurationException($"Data Source needs scheme://host, got: {dataSource}"); Type guard
static bool HasHost(string dataSource) =>
Uri.TryCreate(dataSource, UriKind.Absolute, out var uri) && !string.IsNullOrEmpty(uri.Host); Prevention
- Validate the URL at startup, especially when it is built by string interpolation.
- Prefer full URLs from the Turso dashboard over hand-typed ones.
When it happens
Trigger: Data Source values like 'libsql:my-db' (no '//' — parsed as scheme plus opaque path), 'libsql://' with nothing after, or 'https:///path' — all produce an absolute URI with an accepted scheme but an empty Host, and Open()/GetRemoteUri() then throws.
Common situations: Hand-typing the URL and omitting '://'; string concatenation that drops the slashes ('libsql:' + host); config templating that leaves the host placeholder empty in some environments.
Related errors
- Data Source is not a remote Turso URL: {DataSource}
- Remote Turso URLs must not include query strings or fragment
- Remote Turso URLs must not include embedded user information
- Unsupported remote Turso URL scheme: {uri.Scheme}
- Embedded replica connections are not supported yet by the .N
AI-assisted analysis of tursodatabase/turso@6c72522679 (2026-08-20).
Data as JSON: /api/errors/88f074b614abbe99.
Report an issue: GitHub.