The relationship between serum sodium levels and mortality in congestive heart failure (CHF) patients has not been well-studied previously. The non-linear correlation between serum sodium levels and mortality in patients with heart failure is currently controversial, and the relationship between different serum sodium levels and mortality is disputed. The goal of this study is to look into the relationship between serum sodium levels and all-cause mortality in people with CHF after controlling for other factors. The publicly accessible Mimic III database was the source of data for our study. We use the ICU Admission Scoring System to collect demographic data, laboratory findings, comorbidities, vital signs, and scoring information for each patient. Cox proportional risk analysis, smooth curve fitting, and the Kaplan-Meier survival curve were used to assess the relationship between baseline sodium levels and all-cause mortality in CHF patients. The segmentation regression model discovered a turning point value of serum sodium levels (137.5 mmol/L) between serum sodium levels and all-cause mortality. According to the results of the fully adjusted Cox proportional hazard model, lower serum sodium levels (<137.5 mmol/L) were associated with an increased risk of 30, 90, 365-day, and 4-year all-cause deaths. The HRs and 95th confidence intervals were 0.96 (0.94, 0.99), 0.96 (0.94, 0.99), 0.96 (0.94, 0.98), and 0.96 (0.95, 0.98), respectively; the higher serum sodium levels (≥137.5 mmol/L) were related to an associated multiplied risk of 30, 90, 365-day, and 4-year all-cause deaths; the HRs and 95th confidence intervals were 1.02 (1.00, 1.05), 1.02 (1.00, 1.04), 1.02 (1.00, 1.03), and 1.02 (1.00, 1.03), respectively. Serum sodium levels were u-shaped about all-cause mortality. In individuals with CHF, serum sodium levels are linked to an elevated risk of short-, medium-, and long-term all-cause mortality.