The objectives of this study were to determine the farm-level hyperketolactia (HKL) prevalence, as diagnosed from milk β-hydroxybutyrate (BHB) concentration, on dairy farms milking with an automatic milking system (AMS) and to describe the farm-level housing, management, and nutritional risk factors associated with increased farm-average milk BHB and the within-herd HKL prevalence in the first 45 DIM. Canadian AMS farms (n = 162; eastern Canada n = 8, Quebec n = 23, Ontario n = 75, western Canada n = 55) were visited once between April to September 2019 to record housing and herd management practices. The first test milk data for each cow under 45 DIM were collected, along with the final test of the previous lactations for all multiparous cows, from April 1, 2019 to September 30, 2020. The first test milk BHB was then used to classify each individual cow as having HKL (milk BHB ≥ 0.15 mmol/L) at the time of testing. Milk fat and protein content, milk BHB, and HKL prevalence were summarized by farm and lactation group (all, primiparous, and multiparous). During this same time period, formulated diets for dry and lactating cows, including ingredients and nutrient composition, and AMS milking data were collected. Data from the AMS were used to determine milking behaviors and milk production of each herd during the first 45 DIM. Multivariable regression models were used to associate herd-level housing, feeding management practices, and formulated nutrient composition with first test milk BHB concentrations and within-herd HKL levels separately for primiparous and multiparous cows. The within-herd HKL prevalence for all cows was 21.8%, with primiparous cows having a lower mean prevalence (12.2 ± 9.2%) than multiparous cows (26.6 ± 11.3%). Milk BHB concentration (0.095 ± 0.018 mmol/L) and HKL prevalence for primiparous cows were positively associated with formulated prepartum DMI and forage content of the dry cow diet while being negatively associated with formulated postpartum DMI, the major ingredient in the concentrate supplemented through the AMS, and the PMR-to-AMS concentrate ratio. However, multiparous cows' milk BHB concentration (0.12 ± 0.023 mmol/L) and HKL prevalence were positively associated with the length of the previous lactation, milk BHB at dry off, prepartum diet nonfiber carbohydrate content, and the major forage fed on farm, while tending to be negatively associated with feed bunk space during lactation. This is the first study to determine the farm-level risk factors associated with herd-level prevalence of HKL in AMS dairy herds, thus helping optimize management and guide diet formulation to promote the reduction of HKL prevalence.