The ecological approach to comparative cognition emphasizes that the ecological and social environment are important predictors of cognitive performance. We used this approach to test whether differences in habitat use and social behavior in the facultative Caribbean cleaning goby Elacatinus prochilos predict differences in learning performance in two discriminatory two-choice tasks. This species has two behavioral ecotypes: one that frequently engages in cleaning interactions and inhabits corals in male–female pairs (cleaning gobies) and another that rarely engages in cleaning interactions and inhabits barrel sponges in large groups (sponge-dwellers). We predicted that cleaning gobies would outperform sponge-dwellers in a pattern-cued task, which consisted of identifying the pattern on a plate that consistently provided food, while sponge-dwellers would outperform cleaning gobies in a spatial task, which consisted of identifying the location of the plate. Contrary to our predictions, there was no difference in performance between the two ecotypes. Most of the gobies performed poorly in the pattern-cued task and well in the spatial task. A possible explanation for these results is that the association of a pattern with positive and negative reinforcement may not be a pre-requisite for engaging in cleaning interactions, while spatial skills might be equally required in both ecotypes. Alternatively, the two ecotypes can flexibly adjust to new feeding conditions, which would explain their similar performance in the spatial task. Further research should investigate which aspects of E. prochilos’ social and ecological environment might impose challenges that require spatial cognition and whether individuals can flexibly adjust to new habitats and feeding conditions.