In terms of not achieving the nomination of their party due to losing the primary contests directly, no. However, there have been times when the incumbent president seeking re-election has pulled out of the contest early, for example in 1968 when Lyndon B. Johnson pulled out of the race after winning the first primary in New Hampshire by only 7 percent - thereby technically not losing - or when the incumbent came very close to losing in the primary contests overall.
As the modern primary system in the US presidential race has only been in place since the 1970s, an innovation in part due to the aforementioned 1968 contest, I'll only consider cases since then. The most notable in my opinion took place in the 1976 Republican primaries, when Gerald Ford was challenged for the nomination by Ronald Reagan. Ford won the nomination after a close race, by 1,121 delegates to Reagan's 1078.
The incumbent president being challenged in the primary has become increasingly rare in recent decades; the current challenger to Trump for the nomination, Bill Weld, is the first serious challenger since Patrick Buchanan challenged Bush in 1992. This is partly because conventional wisdom dictates that a strong challenger in the primaries is correlated with the President losing the re-election campaign. It is questionable whether Bill Weld meets the definition of a strong challenger.