diff --git a/ProcessLib/BoundaryCondition/DirichletBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/DirichletBoundaryCondition.cpp
index 4a776f8db17736f509cb0628b2286355402d04d0..b233ed3bc6dd90bee97e1d2213d0abb360198a5d 100644
--- a/ProcessLib/BoundaryCondition/DirichletBoundaryCondition.cpp
+++ b/ProcessLib/BoundaryCondition/DirichletBoundaryCondition.cpp
@@ -45,6 +45,8 @@ void DirichletBoundaryCondition::getEssentialBCValues(
         // TODO: that might be slow, but only done once
         const auto g_idx =
             _dof_table.getGlobalIndex(l, _variable_id, _component_id);
+        if (g_idx == NumLib::MeshComponentMap::nop)
+            continue;
         // For the DDC approach (e.g. with PETSc option), the negative
         // index of g_idx means that the entry by that index is a ghost one,
         // which should be dropped. Especially for PETSc routines MatZeroRows