We study the effect of a hot and dense medium on the binding energy of hadronic molecules with open-charm mesons. We focus on a recent chiral quark-model-based prediction of a molecular state in the $N bar D$ system. We analyze how the two-body thresholds and the hadron-hadron interactions are modified when quark and meson masses and quark-meson couplings change in a function of the temperature and baryon density according to predictions of the Nambu--Jona-Lasinio model. We find that in some cases the molecular binding is enhanced in medium as compared to their free-space binding. We discuss the consequences of our findings for the search for exotic hadrons in high-energy heavy-ion collisions as well as in the forthcoming facilities FAIR or J-PARC.