# Interpreting contradictory goodness of fit

I am studying the effect of categorical indepdent variables on a binary outcome. To do this, I have fitted a glm as following :

Mod = glm(Rep~Var1+Var2+Var3, data=x, family=binomial(link="logit"))


In an attempt to assess the goodness of fit for he model, I used the residual and null deviances to generate a R² (1-RES/NULL) and get very bad fit (0.02).

However, when I perfom a Hosmer and Lemeshow goodness of fit (GOF) test, as follow, I get a p-value of 1.

hoslem.test(x\$Rep, fitted(Mod))


My question is, how to interpret such contradictory results and what could explain the poor fit of the model ? (I selected the one with the lowest AIC, and it returns significant results for explanatory variables)