bitwarden/server · error · BadRequestException
Cannot get a {type} connection outside of a self-hosted inst
Error message
Cannot get a {type} connection outside of a self-hosted instance. What it means
Thrown by GetConnection (GET) in the CloudBillingSync branch when _globalSettings.SelfHosted is false. Cloud Billing Sync connections are only meaningful on self-hosted instances (they bridge a self-hosted org to the cloud), so retrieving one on the cloud/SaaS instance is rejected. Maps to HTTP 400.
Source
Thrown at src/Api/AdminConsole/Controllers/OrganizationConnectionsController.cs:134
}
[HttpGet("{organizationId}/{type}")]
public async Task<OrganizationConnectionResponseModel> GetConnection(Guid organizationId, OrganizationConnectionType type)
{
if (!await HasPermissionAsync(organizationId, type))
{
throw new BadRequestException($"You do not have permission to retrieve a connection of type {type}.");
}
var connections = await GetConnectionsAsync(organizationId, type);
var connection = connections.FirstOrDefault(c => c.Type == type);
switch (type)
{
case OrganizationConnectionType.CloudBillingSync:
if (!_globalSettings.SelfHosted)
{
throw new BadRequestException($"Cannot get a {type} connection outside of a self-hosted instance.");
}
return new OrganizationConnectionResponseModel(connection, typeof(BillingSyncConfig));
case OrganizationConnectionType.Scim:
return new OrganizationConnectionResponseModel(connection, typeof(ScimConfig));
default:
throw new BadRequestException($"Unknown Organization connection Type: {type}");
}
}
[HttpDelete("{organizationConnectionId}")]
public async Task DeleteConnection(Guid organizationConnectionId)
{
var connection = await _organizationConnectionRepository.GetByIdAsync(organizationConnectionId);
if (connection == null)
{
throw new NotFoundException();
}View on GitHub (pinned to e93b962371)
Solutions
- Target a self-hosted Bitwarden instance for CloudBillingSync operations.
- On a self-hosted install, confirm GlobalSettings.SelfHosted=true is set (env: globalSettings__selfHosted=true or appsettings).
- On cloud, use the appropriate cloud-side billing endpoints instead of the connection endpoint.
- Verify EnableCloudCommunication is also true (see ConnectionsEnabled) for the full feature path.
Example fix
// before — calling cloud instance
await client.GetAsync($"organizations/connections/{orgId}/1");
// after — calling self-hosted instance
client.BaseAddress = new Uri(selfHostedUrl);
await client.GetAsync($"organizations/connections/{orgId}/1"); Defensive patterns
Strategy: validation
Validate before calling
// CloudBillingSync is self-hosted-only
var enabled = await client.GetAsync<bool>("organizations/connections/enabled");
if (!enabled) throw new InvalidOperationException("Connections not enabled on this instance.");
if (!isSelfHosted && type == OrganizationConnectionType.CloudBillingSync)
throw new InvalidOperationException("CloudBillingSync requires a self-hosted instance."); Prevention
- Only call CloudBillingSync GET against a self-hosted server.
- Use GET .../connections/enabled to confirm SelfHosted && EnableCloudCommunication.
- On cloud, use cloud billing endpoints instead.
When it happens
Trigger: GET /organizations/connections/{orgId}/1 (CloudBillingSync) against a cloud (non-self-hosted) Bitwarden deployment where _globalSettings.SelfHosted is false.
Common situations: Running the call against api.bitwarden.com (cloud) instead of a self-hosted server; a local dev instance with SelfHosted not set in user secrets / env; configuration drift where a self-hosted install was reconfigured as cloud.
Related errors
- Cannot create a {typedModel.Type} connection outside of a se
- HaveIBeenPwned API key not set.
- You do not have permission to create a connection of type {m
- The requested organization already has a connection of type
- Unknown Organization connection Type: {model.Type}
AI-assisted analysis of bitwarden/server@e93b962371 (2026-08-13).
Data as JSON: /api/errors/479e3dc2022811aa.
Report an issue: GitHub.