Here is a dog who is barking:
"Drooker style dog" by Balthazar, licensed CC-BY-SA 3.0
Here is a dog who is barking up a tree:
"Treeing Fiest" by Scochran4, licensed CC-BY 3.0
There is an animal in the tree that the dog wants to catch.
But what if the dog picked the wrong tree? (Maybe the animal jumped into a different tree and the dog didn't see. Maybe the dog didn't see which tree the animal climbed, and guessed wrong.) Then we could say that the dog is barking up the wrong tree.
When you ask someone for information, and they say, "You're barking up the wrong tree," it means, "I don't have the information you want."
This is metaphorically like the dog (you) trying to catch the animal (information) in the tree (person). The dog is barking up some tree, but the animal isn't in that tree. The animal is in a different tree. Similarly, you're looking for information from a person, but that person doesn't have the information. Someone else knows the information you want.