As a general rule, listening to music while sleeping is only detrimental if it inhibits your ability to get a peaceful night’s rest. If the music is keeping you or someone else awake, for example, then yes… it is actually bad for your health, and you should consider either turning it off, turning it down, or figuring out a different type of audio to listen to that does not impede your ability to rest well.