diff --git a/bilby/core/sampler/ptemcee.py b/bilby/core/sampler/ptemcee.py
index 82cfcf4acc23a1957fb61043f16ae89cc8017dd9..94104ecaf3ad4563fe8699073ee56e0cbf6b6520 100644
--- a/bilby/core/sampler/ptemcee.py
+++ b/bilby/core/sampler/ptemcee.py
@@ -791,6 +791,7 @@ def check_iteration(
     else:
         logger.info("ACT is nan")
         gradient_tau = np.nan
+        gradient_mean_logl = np.nan
         tau_usable = False
 
     if nsteps < tau_int * ci.autocorr_tol: