Domain error at the integrand using QuadGK

Hello, everyone! I am trying to perform the numerical integration of the function \tanh^2(z) using QuadGK.jl with the following code

using Plots
using QuadGK

k(z) = tanh(z)^2
Q = quadgk(k,-Inf,Inf)

but when I try to run, I receive the following error message

DomainError with -0.9999999999999964:
integrand produced Inf in the interval (-1.0, -0.9999999999999929)

I’m not understanding why, since \tanh^2z does not diverge for any z. Does anyone know whats happening?

tanh(x) tends to \pm 1 as x\rightarrow \pm \infty. So the integral you want to evaluate diverges.