What Happens If You Sleep with Monsters Nearby in Minecraft
“The player cannot sleep if a “monster” is within 8 blocks of the bed horizontally (along each axis) and 5 blocks vertically.” It’s been part of the game for a long time. If a monster is standing on the other side of the wall or on the roof, it may be close enough to trigger this.