The recall involves cars from the 2010 through 2012 model years equipped with 2.5-liter engines.
The yellow sac spider, which is attracted to hydrocarbons, builds webs that cause pressure to build in the fuel tank. That increases the risk of fuel leaks and fire.
Mazda recalled cars in 2011 for the same problem. It put covers on the vent line, but has found spiders can get past them.
Mazda will update the cars' software for free beginning this month to ensure that the fuel tank pressure doesn't build up.
Mazda says no injuries or fires have been reported due to the issue.