By allowing gauge anomaly cancellation between fermions in different families we find nonuniversal solutions for Z'
models with the same content of fermions of the standard
model plus three right-handed neutrinos. We also impose constraints from the Yukawa interaction
terms reducing the number of free paraméters. Our solutions
contain as particular cases well-known models in the literature. As an application, we report a
model which evades LHC constraints, flavor changing neutral currents and low energy constraints.
Simultaneously, the model is able to explain the flavor anomalies in the Wilson coefficients C9(µ)
and C10(µ) without modifying the corresponding Wilson coefficients for the first family. In our
approach, this procedure is always possible for Z' masses smaller than ∼ 2.5 TeV.