The surest way to keep snakes out of your yard is to build a snake barrier around it. Failing that, keep your yard clean to eliminate places where snakes like to hang out while they hunt for food. Snakes primarily eat rodents, including mice, rats, moles and squirrels. By making your yard uninviting to rodents, you'll have fewer snakes.

Red-diamond rattlesnake
credit: Design Pics/Design Pics/Getty Images
Barriers are the best protection against rattlesnakes.

Cleaning Your Yard

Snakes like cool, dark places where they can ambush rodents, insects, birds and frogs. Favorite snake hang-outs include piles of firewood, logs, boards, rocks and piles of junk. Eliminate those. Snakes like weeds and tall grass. Pull the weeds. Keep tall grass mowed and there will be fewer "eek" moments when you almost step on a snake. Trim bushes and shrubs growing next to the foundation of your house. Get rid of trash and debris around the banks of ponds or a stream if you have one running through your yard. Snakes are attracted to heavy mulch around shrubs and flowers. A light mulch will give them less cover. Rats, mice and squirrels like seeds in bird feeders. To deter rodents, put the feeders off the ground. You can also put trays under them, use seeds without hulls or put them in suet that contains hot pepper that birds don't mind but rodents hate. Rodents like dog food, too. If you feed your dogs outside, clean up after you feed them. Don't leave garbage in bags outside. Put garbage in a sealed garbage can. If you encounter a snake while cleaning your yard, do not attempt to handle it.

Building a Snake Barrier

One of the best ways to keep snakes out of your yard is to build a snake fence around it. This may be especially necessary if you live in an area infested with poisonous copperheads or rattlesnakes. Cut a 30-inch high barrier of 1/4-inch galvanized hardware cloth and bury the bottom 3 to 6 inches into the ground. Slant the fence at a 30-degree angle facing approaching snakes. If you already have a fence around your yard, build the barrier at the outside bottom. If you need stakes to support your snake barrier, put them on the inside of the barrier, not the outside. If you have gates into your yard, make sure they fit tightly and keep them closed.

Foiling Climbing Snakes

The black rat snake, species of which are found throughout the United States, can climb up brick walls and tree trunks. To foil these and other climbing snakes, prune any limbs overhanging your property from another yard. Put a 12-inch-wide strip of metal flashing around the base of trees and at the top of fences.

Avoiding Repellent Frustration

The ability of snakes to detect odor is limited. Unless a snake pokes its tongue out when it encounters a repellent, it won't be affected and may not be deterred. A study conducted by Gary J. San Julian and David K. Woodward at North Carolina State University showed that home "snake repellent" remedies do not work. These include musk from the predatory king snake, artificial skunk scent, cayenne pepper spray, tacky bird repellent, gourd vines, sulfur, cedar oil, moth balls, lime, liquid smoke and creosote.The Environmental Protection Agency has registered snake repellents containing sulfur and naphthalene, but EPA registration does not mean that they actually repel snakes, only that they will not harm the user or the natural environment. "The Efficacy of Naphthalene and Sulfur Repellents to Cause Avoidance Behavior in the Plains," a study by Dennis M. Farraro of the University of Nebraska, found that naphthalene-sulfur formulations against nonpoisonous garter snakes were ineffective.