The Danish King Erik I Ejegod (The Good) died in Paphos, Cyprus, 1736 miles / 2794 km from the then capital of Denmark, Roskilde.
Erik, who was born around 1056 or 1060 and reigned from 1095 to 1103, was the fourth of five brothers (sons of Sweyn II Estridsson) who all became King of Denmark (not concurrently, they reigned at different times between 1076 and 1134). Before the pilgrimage, Erik also travelled to Italy in 1098-99, visiting the pope and founding a guest home for pilgrims in Piacenza. Erik seems to have been a physically imposing man with a strong personality; he had at least three illegitimate children. The name 'Ejegod' means 'eternal good', given to him because he upheld the law to protect the people from powerful men.
Erik I set out on a pilgrimage to the Holy Land with his wife Boedil Thurgotsdatter, probably in early 1103 (some sources state 1100), travelling via Novgorod and Constantinople. Despite falling ill in the Byzantine capital while a guest of the emperor Alexios I Komnenos, they travelled on to Cyprus where, on 10th July 1103, Erik died of a fever. He was buried in Paphos, though the exact location of his grave is unknown. Erik was the first king to go a pilgrimage to the Holy Land following the recapture of Jerusalem during the First Crusade. He was succeeded as King of Denmark by his younger brother Niels (1104 - 1134) who was chosen ahead of the acting regent, Eric's illegitimate son Harald Kesja.
One of the cemeteries in Cyprus where he may be buried. He reigned from 1095 to 1103. Image source: cphpost.dk
His wife continued on to Jerusalem (Mount of Olives) and died there, also in 1103 (1995 miles / 3211 km from home).
Note: One of the sources above wrongly states that Eric I was the only Danish king to be buried abroad. Canute (king of England 1016-35, Denmark 1018-35, Norway 1028-35) was buried in Winchester and his son Harthacnut (King of Denmark 1035-42, England 1040-42) is also there.
Erik 1. Ejegod (in Danish)