The Bible does not require a specific posture or place for prayer. Jonah, for example, prayed in the belly of a great fish. Jesus prayed face down in an olive garden. According to the superscription of Psalm 142, David prayed in a cave.
What the superscription does not state but the psalm itself clearly indicates is that David was hanging on by the barest of threads. Slowly read aloud and carefully listen for the intense pathos of these words: “When my spirit was overwhelmed within me, then You knew my path. In the way in which I walk they have secretly set a snare for me. Look on my right hand and see, for there is no one who acknowledges me; refuge has failed me; no one cares for my soul. I cried out to You, O Lord: I said, ‘You are my refuge, my portion in the land of the living. Attend to my cry, for I am brought very low; deliver me from my persecutors, for they are stronger than I. Bring my soul out of prison, that I may praise Your name; the righteous shall surround me, for You shall deal bountifully with me.’”
While you may never have prayed in a physical cave, how many times have you found yourself in the cave of being overwhelmed (v. 3), or the cave of vulnerability and exposure—without refuge (v. 4), or the cave of loneliness (v. 4), or the cave of humiliation (v. 6), or the cave of persecution and mistreatment (v. 6), or the cave of spiritual imprisonment (v. 7)?
David’s been there. Done that. And, was delivered by prayer.