We perform for the first time a dedicated analysis of cosmological constraints on DFSZ QCD axion models. Such constructions are especially interesting in light of the recent Xenon-1T excess and of hints from stellar cooling. In DFSZ models, for ma 0.1 eV, scatterings of pions and muons can produce a sizable cosmic background of thermal axions, that behave similarly to massive neutrinos. However, the pion coupling depends on the alignment between the vevs of two Higgs doublets, and can be significantly suppressed or enhanced with respect to the KSVZ scenario. Using the latest Planck and BAO data, we find ma ≤ 0.2 eV at 95% C.L., when the axion coupling to pions caπ is maximal. Constraints on ma, instead, can be significantly relaxed when caπ is small. In particular, we point out that in the so-called DFSZ-II model, where the axion coupling to leptons does not vanish simultaneously with caπ, production via muons gives ma ≤ 0.6 eV at 95% C.L., whereas in the DFSZ-I model bounds on ma can be fully lifted. We then combine cosmological data with recent hints of a DFSZ axion coupled to electrons from the Xenon-1T experiment, finding in this case that the axion mass is constrained to be in the window 0.07 eV ma 1.8 (0.3) eV for the DFSZ-I (DFSZ-II) model. A similar analysis with stellar cooling hints gives 3 meV ma 0.2 eV for DFSZ-II, while no constraint arises in the DFSZ-I case. Forthcoming CMB Stage 4 experiments will be able to further test such scenarios; for instance the Xenon-1T window should be fully probed at 2σ for a DFSZ-I axion.