As Hornblower's second ruse is in play, just after Matthews warns him the Spanish suspect something, one line of dialogue makes clear, as the captain of the Spanish ship orders one of his officers: "Señala al almirante. Avisa que vamos a abrir fuego sobre piratas ingleses." Translated: "Signal the admiral. Say we are about to open fire on English pirates".
The Spanish fort used is the prison Peniche Fortress on the central coast of Portugal. As of 2019, it's closed to the public for restoration.
The lines that Kennedy quotes when he wakes up and sees Hornblower and the Duchess are taken from Shakespeare's Antony and Cleopatra (Act4; scene 15). They are spoken by Cleopatra when she realizes Antony has died.
The plot of Horblower's capture by the Spanish is based on real events: in 1797, while returning from a diplomatic mission aboard HMS Minerve, commodore Horatio Nelson (the real life inspiration for Hornblower) was indeed caught in heavy fog in the middle of the Spanish fleet, that was escorting a shipment of mercury from the Americas. Among of the Spanish ships was, indeed, the 80 guns San Nicolas. Unlike the plot of the film, Nelson did escape due to the fog, reported the Spanish squadron of the admiralty and later captured the San Nicolas in the following Battle of Cape St. Vincent, in February 1797.
Robert Lindsay played Benedict opposite Cherie Lunghi as Beatrice in the 1984 BBC TV production of Much Ado About Nothing.