"The gates of death" is a Hebraism that almost personifies the grave and death. Observe the Cambridge commentary on Job 38:17 -
- have the gates of death Or, were the gates? Death is personified; it is Sheol, the place of the dead, ch. Job 28:22. This
is a lower deep than the recesses of the sea; Job, no doubt, went down
We see this in the surrounding material (V6-8):
On what were its [the earth] foundations set, or who laid its
cornerstone, ... Who enclosed the sea behind doors when it burst forth from the womb
Thus, there is considerable literary metaphor and licence in the passage of Job 38.
There is a similar phenomenon in other places that talk about death and sheol/hades. For example, in Isa 38, Isaiah expresses a lament in very poetic language using numerous metaphors such as (V12, 13):
My dwelling has been picked up and removed from me like a shepherd’s
tent. I have rolled up my life like a weaver; He cuts me off
from the loom; from day until night You make an end of me. I composed myself until the morning. Like a lion He breaks all my
bones; from day until night You make an end of me.
In the case of Ps 9 we have the helpful comments of Ellicott:
(13, 14) It is natural to take these verses as the cry for help just
mentioned. Consider.—Literally, see my suffering from my haters.
My lifter up from the gates of death.—For the gates of sheol, see Note
to Psalm 6:5. (Comp. Psalm 107:18, and the Homeric phrase “the gates
of Hades.”) We might perhaps paraphrase “from the verge of the grave,”
if it were not for the evident antithesis to “gates of the daughter of
Zion” in the next verse. We understand, therefore, “gates” in sense of
“power,” “rule,” the gate being the seat of the judge or king, and so,
like our “court,” synonymous for his power. (Comp. Sublime Porte.)
This shows the pattern of the Hebrew metaphor well. There are no literal gates of sheol/hades.