The phosphodiester bond forms between the 5'-phosphate group of one nucleotide and the 3'-hydroxyl group of the second nucleotide, in DNA and RNA.