SRD 5.1 rules text (the 2014 rules), under adventuring.
Heroic though they might be, adventurers can't spend every hour of the day in the thick of exploration, social interaction, and combat. They need rest-time to sleep and eat, tend their wounds, refresh their minds and spirits for spellcasting, and brace themselves for further adventure.
Adventurers can take short rests in the midst of an adventuring day and a long rest to end the day.
Short Rest
A short rest is a period of downtime, at least 1 hour long, during which a character does nothing more strenuous than eating, drinking, reading, and tending to wounds.
A character can spend one or more Hit Dice at the end of a short rest, up to the character's maximum number of Hit Dice, which is equal to the character's level. For each Hit Die spent in this way, the player rolls the die and adds the character's Constitution modifier to it. The character regains hit points equal to the total. The player can decide to spend an additional Hit Die after each roll. A character regains some spent Hit Dice upon finishing a long rest, as explained below.
Long Rest
A long rest is a period of extended downtime, at least 8 hours long, during which a character sleeps or performs light activity: reading, talking, eating, or standing watch for no more than 2 hours. If the rest is interrupted by a period of strenuous activity-at least 1 hour of walking, fighting, casting spells, or similar adventuring activity-the characters must begin the rest again to gain any benefit from it.
At the end of a long rest, a character regains all lost hit points. The character also regains spent Hit Dice, up to a number of dice equal to half of the character's total number of them (minimum of one die). For example, if a character has eight Hit Dice, he or she can regain four spent Hit Dice upon finishing a long rest.
A character can't benefit from more than one long rest in a 24-hour period, and a character must have at least 1 hit point at the start of the rest to gain its benefits.
The average a character regains for each Hit Die spent on a short rest, by die size and Constitution modifier:
How resting works
A short rest is at least an hour of downtime: eating, drinking, reading, tending wounds. At the end of it, you can spend Hit Dice to heal. Roll each one and add your Constitution modifier, one at a time, deciding after each roll whether to spend another. You have as many Hit Dice as your level. Warlock spell slots, a fighter’s Second Wind and Action Surge, and a monk’s ki all come back on a short rest.
A long rest is at least 8 hours, spent sleeping and doing light activity like reading, talking, eating or standing watch for no more than 2 hours. At the end, you regain all lost hit points and half your total Hit Dice (at least one), and most classes get back their spell slots and daily features. You need at least 1 hit point to start one, and you can benefit from only one long rest in 24 hours.
If an hour or more of strenuous activity (walking, fighting, casting spells or similar) interrupts a long rest, you have to start it again.
Common questions
How long is a short rest?
At least 1 hour, doing nothing more strenuous than eating, drinking, reading and tending wounds.
How many Hit Dice do I get back on a long rest?
Half your total number of Hit Dice, rounded down, with a minimum of one. A 7th-level character gets back 3. In the 2024 rules you get all of them back.
Can I keep watch during a long rest?
Yes. Standing watch is light activity, and you can do up to 2 hours of it during an 8-hour long rest.
What interrupts a long rest?
At least an hour of strenuous activity, such as walking, fighting or casting spells. A short fight doesn’t ruin it under the 2014 rules; you carry on resting.
How many long rests can I take in a day?
You can benefit from only one long rest in any 24-hour period, and you need at least 1 hit point when it starts.
How many short rests can I take?
There’s no limit. The Dungeon Master’s Guide expects about two short rests per adventuring day, but it’s up to the DM how often the party can safely stop for an hour.