Debris flows are one of the perilous landslide-related hazards due to their fast flow velocity, large impact force, and long runout, in association with poor predictability. Debris-flow barriers that can minimize the energy of debris flows have been widely constructed to mitigate potential damages. However, the interactions between debris flows and barriers remain poorly understood, which hampers the optimal barrier installation against debris flows. Therefore, this study examined the effect of barrier locations, in particular source-to-barrier distance, on velocity and volume of debris flows via the numerical approach based on smoothed particle hydrodynamics (SPH). A debris-flow event was simulated on a 3D terrain, in which a closed-type barrier was numerically created at predetermined locations along a debris-flow channel, varying the source-to-barrier distance from the initiation point. In all cases, the closed-type barrier significantly reduced the velocity and volume of the debris flows, compared to the cases without a barrier. When the initial volume of source debris was small, or when the flow path was short, the barriers effectively blocked the debris flow regardless of the source-to-barrier distance. However, with a long flow path, installation of the barrier closer to the initiation location appeared more effective by preventing the debris volume from growing by entrainment. Our results contribute to a better understanding of how source-to-barrier distance influences debris-flow behavior, and show that the methodology presented herein can be further used to determine optimum and efficient designs for debris-flow barriers.