Joseph continues to languish in a special prison attached to the house of the captain of the guard (Genesis 39:11–20). While Joseph's former master held that position (Genesis 39:1), Scripture does not use the name Potiphar from this point forward. It's unclear if Potiphar is still in that role, or if he has been replaced. After Joseph has been there "some time," likely several years, two new prisoners arrive. Pharaoh has become angry at both his chief cupbearer and his chief baker. He throws them into the prison, also called "the pit" or "the dungeon," where Joseph is. Genesis doesn't tell us what their offenses were (Genesis 40:1–3).

Just as in his prior role, Joseph's diligence and character have led to recognition (Genesis 39:21–23). He is given a kind of caregiver's role over these two new men. They, as well, are held for "some time," likely another period of years. In a dictator-driven legal system, a prisoner might be subject to almost any fate at any time. One night, both men experience vivid, impactful dreams. Egyptian religion took dreams very seriously, but these are especially jarring visions. The men are disturbed enough by the dreams that Joseph takes notice (Genesis 40:4–7).

In response to their concern, Joseph assures them that God can interpret dreams, and Joseph will pass those truths along. The first man's dream involves three productive grape vines; Joseph indicates that the man will be restored to his former position in three days. In addition, Joseph asks the man to speak to Pharaoh on his behalf. While Joseph accepts God's will for his life, he also recognizes the opportunity to advocate for his own release (Genesis 40:8–15).

The second man's dream also implies a resolution in three days, but not a happy one. The expression "to lift one's head" evokes a person looking downwards in defeat or shame as their face is raised into a more confident posture (Psalm 3:3). Both men will have their "heads lifted" by Pharaoh, but the baker will immediately be executed, and his corpse left to rot (Genesis 40:16–19).

These predictions come about exactly as Joseph predicted. Three days later, the king brings out the two men as part of his birthday celebration. One is restored to his prior role, the other is killed and his body left for scavengers. Despite this, the newly freed cupbearer makes no mention of Joseph. Either out of fear, caution, or some other motive, he says nothing. He does not lose memory of Joseph, but "forgets" him by setting his plea out of his mind (Genesis 40:20–23)