Abstract Structural changes in dynamical systems are often related to the appearance or disappearance of orbits connecting two stationary points (either heteroclinic or homoclinic). To compute the connecting orbits, the boundary value problem which is posed on the real line is frequently replaced by one on a finite interval. Then the problem is solved on the finite interval using appropriate numerical methods. In this work, we use a rational spectral approach to compute the connecting orbits. This method avoids truncating the problem to a finite interval and produces very accurate numerical solutions with a fairly small number of computational points. Numerical examples indicate that the method compares favorably with the existing ones.