It's highly plausible that dogs wag their tails while sleeping because they're having pleasant dreams, though this isn't definitively proven scientifically. During sleep, dogs may exhibit various behaviors such as chewing, leg stretching, growling, twitching, and tail wagging. These actions might be due to physical discomfort or, quite possibly, they could be experiencing a dream.

Our understanding of whether dogs dream is limited, but many observations suggest they do. In humans, most dreams occur during the rapid eye movement (REM) sleep phase, and dogs also experience REM sleep. During this stage, a dog's breathing becomes irregular, and they may exhibit muscle twitches. Common dream-related behaviors include leg paddling, twitching, and vocalizations, indicating that dogs likely do dream. The fact that dogs experience REM sleep is a huge hint that they dream as well, these sleep patterns are highly correlated with dreaming in mammals.
Signs Your Dog Might Be Dreaming
1. Tail Wagging
If your dog wags its tail while sleeping, it often indicates they are having a good dream, which suggests they are having a positive experience. If your dog appears happy during these events, they are more likely to be dreaming. This common sleep behavior indicates positive feelings in the sleeping dog.
2. Twitching
When a dog twitches during sleep, it may be experiencing a nightmare. The dream content might evoke fear, resulting in these twitching movements. These involuntary movements are quite common when dogs are experiencing a negative dream, and it is perfectly fine for them to twitch as long as they are not having a seizure.
3. Drooling
If your dog drools while sleeping, it suggests they are in a deep, restful sleep and might be dreaming about food. This shows the dog is possibly having a delicious dream, and it is dreaming of its favorite treats.
4. Growling
When dogs growl during sleep, it might signify that they are dreaming of a situation like fighting with another dog. A competitive dog may likely growl when it is in a fight in a dream. This type of scenario is extremely common among puppies.