If you have a pet bird, chances are that it sleeps at night. In the wild, most birds are diurnal (awake during the day and asleep at night), but nocturnal bird species like owls wake up when it gets dark and hunt their prey in the nighttime.
In the wild, birds look for covert areas at night to protect them from predators and the elements. They often roost in trees or shrubs, and some birds, like the goldfinches that you may have in your yard, will nestle into the bark of coniferous trees on winter nights. Nuthatches, which are another common backyard bird, will roost in old woodpecker holes.
Birds are light sleepers, and their awareness of the environment is not completely switched off during sleep. They are able to scurry to safety at the slightest hint of danger. Some birds, such as ducks, even keep one eye open while they sleep. This is known as unihemispheric slow-wave sleep, or USWS, and it allows them to keep an eye on their surroundings.
In addition to their ability to scurry to safety, birds also have the remarkable ability to cling to objects such as tree branches or the inside of a chimney. This is a natural behavior that allows them to rest during periods of inactivity, such as when they are molting. During this time, a molting bird will need to rest for long periods of the day and might even sleep all night.