Cognitive abilities, such as learning and flexibility, are hypothesized to aid behavioral adaptation to urbanization. Although growing evidence suggests that cognition may indeed facilitate persistence in urban environments, we currently lack knowledge of the cognitive abilities of many urban taxa. Recent methodological advances, including radio frequency identification (RFID), have extended automated cognitive testing into the field but have yet to be applied to a diversity of taxa. Here, we used an RFID-enabled operant conditioning device to assess the habituation, learning and cognitive flexibility of a wild population of raccoons (Procyon lotor). We examined how several biological and behavioral traits influenced participation and performance in testing. We then compared the cognitive performance of wild raccoons tested in natural conditions with that of wild-caught raccoons tested in captivity from a previous study. In natural conditions, juvenile raccoons were more likely to habituate to the testing device, but performed worse in serial reversal learning, compared with adults. We also found that docile raccoons were more likely to learn how to operate the device in natural conditions, which suggests a relationship between emotional reactivity and cognitive ability in raccoons. Although raccoons in both captive and natural conditions demonstrated rapid associative learning and flexibility, raccoons in captive conditions generally performed better, likely owing to the heightened vigilance and social interference experienced by raccoons in natural conditions. Our results have important implications for future research on urban carnivores and cognition in field settings, as well as our understanding of behavioral adaptation to urbanization and coexistence with urban wildlife.