A rainbow can only form under the following conditions:
The Sun must be above the horizon and not be obscured by clouds, mountains, or other obstacles.
The Sun has to be quite low in the sky. If you are at the same elevation as your horizon, the Sun's altitude must be below 42° to create a rainbow that can be seen from your perspective.
The air opposite the Sun, as seen from your position, must be filled with a large number of water droplets.
Rainbows always appear in the sky opposite the Sun. So, if you have your back to the Sun, the rainbow will arch across the sky in front of you.