Sleep disorders have a significant negative impact on mental and physical health, especially among the elderly. Various factors can affect the sleep quality of elderly people. The aim of this research to investigate the effect of urban and rural environments on the sleep quality of elderly people with emphasis on physical activity. Four hundred and thirty-nine elderly people (226 city residents and 213 village residents) in urban and rural areas of Bushehr (Southern Iran), volunteered to participate in the present study. Information was collected via the General information questionnaire and Petersburg Sleep Questionnaire. The results showed that active elderly women (p < 0.001), and total active elderly (male + female) (p < 0.001) living in urban areas compared to inactive elderly and also in rural areas active elderly women (p < 0.001), active elderly men (p < 0.001) and total active elderly (male + female) (p < 0.001) had better overall sleep quality in compared to inactive elderly. Also, elderly men (p < 0.001) and the total elderly (male + female) (p < 0.001) living in urban areas had better sleep quality than the elderly in rural areas. Based on the findings, it can be concluded that the way of life (being active) as well as the living environment can affect the sleep quality of elderly people, so that active elderly people and also elderly people living in urban environments had better sleep quality.