Measurements of longitudinal flow correlations are presented for charged particles in the pseudorapidity range | η| < 2.4 using 7 and 470 μ b - 1 of Pb+Pb collisions at sNN=2.76 and 5.02 TeV, respectively, recorded by the ATLAS detector at the LHC. It is found that the correlation between the harmonic flow coefficients vn measured in two separated η intervals does not factorise into the product of single-particle coefficients, and this breaking of factorisation, or flow decorrelation, increases linearly with the η separation between the intervals. The flow decorrelation is stronger at 2.76 TeV than at 5.02 TeV. Higher-order moments of the correlations are also measured, and the corresponding linear coefficients for the kth -moment of the vn are found to be proportional to k for v3, but not for v2. The decorrelation effect is separated into contributions from the magnitude of vn and the event-plane orientation, each as a function of η. These two contributions are found to be comparable. The longitudinal flow correlations are also measured between vn of different order in n. The decorrelations of v2 and v3 are found to be independent of each other, while the decorrelations of v4 and v5 are found to be driven by the nonlinear contribution from v22 and v2v3, respectively.