Where does the phrase “to bark up the wrong tree” come from and What does it mean?

The phrase “to bark up the wrong tree” means to mistake one’s course of action; to be on the wrong course; to have one’s attention diverted from the intended object.

Literally, this American phrase referred to a hunting dog used in the pursuit of raccoons.

When this nocturnal animal takes to a tree, the dog is supposed to stay at the foot of the tree and bay until its master arrives. But, in the dark, if the dog mistakes the tree in which the ‘coon has taken refuge, the hunter may lose it entirely.

The expression must have been very popular in the early nineteenth century, especially by writers of western life and tales, for in rapid succession it appeared in the works of James Hall, David Crockett, and Albert Pike.