LemmyNet/lemmy · error
err getting local site: {e:?}
Error message
err getting local site: {e:?} What it means
SiteView::read_local queries the local_site row and returns LocalSiteNotSetup when none exists; any other DB failure is wrapped into this anyhow error. It means the instance's local site record could not be loaded.
Source
Thrown at crates/db_views/site/src/impls.rs:77
CACHE
.try_get_with((), async move {
let conn = &mut get_conn(pool).await?;
let local_site = site::table
.inner_join(local_site::table)
.inner_join(instance::table)
.inner_join(
local_site_rate_limit::table
.on(local_site::id.eq(local_site_rate_limit::local_site_id)),
)
.select(Self::as_select())
.first(conn)
.await
.optional()?
.ok_or(LemmyErrorType::LocalSiteNotSetup)?;
Ok(local_site)
})
.await
.map_err(|e: Arc<LemmyError>| anyhow::anyhow!("err getting local site: {e:?}").into())
}
/// A special site bot user, solely made for following non-local communities for
/// multi-communities.
pub async fn read_system_account(pool: &mut DbPool<'_>) -> LemmyResult<Person> {
let site_view = SiteView::read_local(pool).await?;
Person::read(pool, site_view.local_site.system_account).await
}
}
pub async fn user_backup_list_to_user_settings_backup(
local_user_view: LocalUserView,
pool: &mut DbPool<'_>,
) -> LemmyResult<UserSettingsBackup> {
let lists = LocalUser::export_backup(pool, local_user_view.person.id).await?;
let blocking_keywords = LocalUserKeywordBlock::read(pool, local_user_view.local_user.id).await?;
let discussion_languages = LocalUserLanguage::read(pool, local_user_view.local_user.id).await?;
View on GitHub (pinned to 439734dd63)
Solutions
- Complete instance setup so the local_site row exists (finish the Lemmy bootstrap/admin setup)
- Verify DB connection settings point at the correct, migrated database
- Run pending migrations and restart
- Inspect the inner debug error to distinguish not-setup from a connection failure
Example fix
// before
let site = SiteView::read_local(pool).await?; // panics-equivalent when local_site absent
// after
if let Err(e) = SiteView::read_local(pool).await {
eprintln!("local site not available yet, deferring startup: {e}");
// wait/retry until setup completes
} Defensive patterns
Strategy: retry
Validate before calling
let exists: Option<i32> = sqlx/diesel query "SELECT 1 FROM local_site" ...optional().await?;
if exists.is_none() {
// defer startup until instance setup is complete
} Try / catch
match SiteView::read_local(pool).await {
Ok(site) => start_with(site),
Err(e) => { warn!("local site not ready: {e}"); wait_and_retry(); }
} Prevention
- Finish instance setup before enabling federation workers
- Confirm DB hostname/database name in config points to the migrated DB
- Run migrations on every deploy
- Alert on LocalSiteNotSetup at boot
When it happens
Trigger: Calling read_local on an instance whose local_site row is absent (fresh/undone setup) or where the underlying query fails — connection problems, wrong DB, migrations not applied.
Common situations: Starting federation/tasks before completing Lemmy setup (local site never created); pointing at the wrong database; failed or partial migrations; DB connectivity loss at boot.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- activity is from before lemmy 0.19
- err getting actor {actor_type:?} {actor_apub_id}: {e:?}
- err getting activity: {e:?}
- err getting id: {e:?}
- {}: next id to send is not as expected: {:?} != {:?}
AI-assisted analysis of LemmyNet/lemmy@439734dd63 (2026-09-06).
Data as JSON: /api/errors/1c39c34976c119ff.
Report an issue: GitHub.