diff --git a/server/service/osquery.go b/server/service/osquery.go index 3d0c34bd81..0e3fa07d39 100644 --- a/server/service/osquery.go +++ b/server/service/osquery.go @@ -811,6 +811,8 @@ func (svc *Service) policyQueriesForHost(ctx context.Context, host *fleet.Host) if !svc.shouldUpdate(policyReportedAt, svc.config.Osquery.PolicyUpdateInterval, host.ID) && !host.RefetchRequested { return nil, false, nil } + // This must come after the check above to avoid unnecessary queries to the database. Most + // requests from live connected hosts will not reach this point disablePolicies, err := svc.disablePoliciesDuringSetupExperience(ctx, host) if err != nil { return nil, false, ctxerr.Wrap(ctx, err, "check if host is in setup experience")