Russel Shaffer, president of the Alameda County Beekeepers Association, uses a smoker as he works with his hives in his backyard in Fremont, CA Friday July 27th, 2012. Russel won an 18-year battle with the city of Fremont and his neighbors to be able to keep bees in his backyard. Fremont, CA Friday July 27th, 2012

Photo: Michael Short, Special To The Chronicle

Russel Shaffer, president of the Alameda County Beekeepers...

Image 2 of 6

Russel Shaffer was cited for not having a "fancier's permit" and for not getting neighborhood approval.

Photo: Michael Short, Special To The Chronicle

Russel Shaffer was cited for not having a "fancier's permit" and...

Image 3 of 6

It took Shaffer 13 months, a $600 fine and multiple hearings before he was allowed to keep his backyard Fremont beehives.

Photo: Michael Short, Special To The Chronicle

It took Shaffer 13 months, a $600 fine and multiple hearings before...

Image 4 of 6

It took Shaffer 13 months, a $600 fine and multiple hearings before he was allowed to keep his backyard Fremont beehives.

Photo: Michael Short, Special To The Chronicle

It took Shaffer 13 months, a $600 fine and multiple hearings before...

Russel Shaffer, president of the Alameda County Beekeepers Association, works in his garage in Fremont, CA Friday July 27th, 2012, scraping honeycomb into a sieve which will separate honey from the waxy comb. Russel won an 18-year battle with the city of Fremont and his neighbors to be able to keep bees in his backyard. Fremont, CA Friday July 27th, 2012

With the widespread popularity of backyard beekeeping, hives are popping up on Bay Area roofs and in backyards at a fast clip.

All good for helping the beleaguered honeybee, but not always so good for keeping peace with neighbors worried about stings. As the ranks of amateur beekeepers swell, there's been an uptick in calls from neighbors asking about the ordinances that regulate beekeeping.

While some cities outlaw bees, some such as San Francisco welcome beekeepers and don't require any specific permits. Others such as Palo Alto say it's OK with written permission from immediate neighbors. Throughout the state, there's a patchwork quilt of apiary rules that until recently have stayed buried in rarely enforced zoning codes and animal control ordinances that categorize bees as everything from insects to "livestock" and even "exotic animals."

There is also the tricky question of whether to follow rules that the government does not enforce. California law requires beekeepers to register with their county, but the state does not provide financing for enforcement. Many renegade beekeepers operate on the assumption it's better to beg forgiveness and give honey gifts later than to ask for permission first, but without first checking the regulations, many new beekeepers are being forced to take down their hives or fight lengthy legal battles to maintain their hobby.

Russel Shaffer, president of the Alameda County Beekeepers Association, had had two hives in his Fremont backyard for four years when an animal control officer knocked on his door in 2010.

"They weren't hidden; my neighbors were aware of them," Shaffer said.

He was written up for not having a "fancier's permit" and for not acquiring neighborhood approval for his bees. He immediately applied for the permit, but his application was denied two weeks later because one of his four neighbors wanted his hives removed.

After three more hearings at Shaffer's request, and paying a $600 fine, a Superior Court judge allowed Shaffer to keep his bees because there was no evidence anyone had been stung in four years.

"It was a 13-month ordeal," Shaffer said. "All of which could have been avoided if I got the permit first."

Woodland beekeeper Rick Purvis decided not to fight the system in Yolo County.

Purvis was told to remove hives he kept at a friend's house in Winters because it's illegal to have "exotic animals not used in circuses or carnivals" in the incorporated areas of Yolo County.

A beekeeper for more than three decades, Purvis relocated them to an unincorporated area near Lake Berryessa in neighboring Napa County.

"I hear constantly from people asking where they can put their hives in Yolo County, and it's ironic because UC Davis is here, with one of the largest bee research facilities in the nation and a big promoter of beekeeping, yet it's illegal to have your own bees here," he said.

If the rules confuse would-be and longtime beekeepers alike, they are even more confusing to city officials who are being asked to interpret laws that in many cases have never been examined before.

Foster City bans beekeeping. San Jose residents must apply for a permit.

In Los Gatos and unincorporated areas of Santa Clara County, apiaries must be 1,000 feet from any "residence, church, school, public building, corral or water area."

In Marin County, it can vary street by street in some cases in the same town. San Rafael, Tiburon, Fairfax and Sausalito require permits. Novato allows backyard hives as long as they "are not for commercial purposes." Mill Valley bans backyard beekeeping. Larkspur and San Anselmo have no regulations. Within Corte Madera, some neighborhoods ban beekeeping, others don't.

Just as some beekeepers prefer to go renegade to avoid the bureaucracy, some neighbors also take matters into their own hands. Hives have been sprayed with chemicals or toppled in San Francisco, most recently in community gardens in Hayes Valley Farm and Alemany Farm.

"I always recommend talking to any neighbors who are able to see the hives, just to get their approval and then when the honey comes, spreading that around a bit," said Robert MacKimmie of City Bees, who has nearly 70 hives in San Francisco, and some in Marin and San Mateo.

"Generally, if they can't see the hives, it's not going to become an issue, because they'd never know the bees are there," he said.