A compound of formula I: or a pharmaceutically acceptable salt thereof, wherein: X is -N= or -CH=; X 1 is -N= or -C(R 5)=; R 1 is R 1a is or C 1-6 straight chain aliphatic optionally substituted with one or more groups independently selected from -OH or 5-membered heteroaryl having 1-2 heteroatoms independently selected from nitrogen, oxygen or sulfur; each R 1b is independently hydrogen, C 1-4 alkyl, or two R 1b groups are optionally taken together to form an oxo group; each of R 1c and R 1d is independently hydrogen or C 1-4 alkyl; R 2 is -O-CH 2 -Ring A, -NH-CH 2 -Ring A, or -O-CH 2 CH 2 -Ring A; Ring A is unsubstituted phenyl, unsubstituted furanyl, or pyridinyl optionally substituted with R A5; each of R A1 is independently halogen, -CN, -C N 2, -N 2, -OR, -C R, -N 3, an optionally substituted 5- or 6-membered heterocyclyl or heteroaryl having one or two heteroatoms independently selected from nitrogen, oxygen, or sulfur, or C 1-4 alkyl optionally substituted with one or more halogen; each R is independently hydrogen or C 1-4 alkyl optionally substituted with one or more halogen; R A2 is -Cl, -Br, -I, -CN, -C N 2, -N 2, -OR, -C R, -N 3, C 1-4 alkyl with no branching at the benzylic position and optionally substituted with one or more halogen, or an optionally substituted 5- or 6-membered heterocyclyl or heteroaryl having one or two heteroatoms independently selected from nitrogen, oxygen or sulfur; n is 1 to 4; R A3 is -H or -F; R A4 is -F or -OR; R A5 is -OR or -N 2; R 3 is -C N(R 3a) 2, -OR 3b, -C H, -C OR, or -N(R 3c) 2; each R 3a is independently hydrogen or C 1 alkyl optionally substituted with one or more groups independently selected from halogen or 1-pyrrolidinyl; R 3b is hydrogen or C 1-4 alkyl optionally substituted with one or more groups independently selected from halogen, C 1-4 alkyl, C 1-4 haloalkyl, oxo, or -N 2; each R 3c is independently hydrogen or C 1-4 alkyl optionally substituted with one or more groups independently selected from halogen, C 1-4 alkyl, C 1-4 haloalkyl, oxo, or -N 2; R 4 is R or halogen; and R 5 is hydrogen, methyl or -N 2; wherein the term "alkyl" includes saturated aliphatic groups, including straight-chain alkyl groups, branched-chain alkyl groups, cycloalkyl (alicyclic) groups, alkyl substituted cycloalkyl groups, and cycloalkyl substituted alkyl groups. X is -N= or -CH=; X 1 is -N= or -C(R 5)=; R 1 is R 1a is or C 1-6 straight chain aliphatic optionally substituted with one or more groups independently selected from -OH or 5-membered heteroaryl having 1-2 heteroatoms independently selected from nitrogen, oxygen or sulfur; each R 1b is independently hydrogen, C 1-4 alkyl, or two R 1b groups are optionally taken together to form an oxo group; each of R 1c and R 1d is independently hydrogen or C 1-4 alkyl; R 2 is -O-CH 2 -Ring A, -NH-CH 2 -Ring A, or -O-CH 2 CH 2 -Ring A; Ring A is unsubstituted phenyl, unsubstituted furanyl, or pyridinyl optionally substituted with R A5; each of R A1 is independently halogen, -CN, -C N 2, -N 2, -OR, -C R, -N 3, an optionally substituted 5- or 6-membered heterocyclyl or heteroaryl having one or two heteroatoms independently selected from nitrogen, oxygen, or sulfur, or C 1-4 alkyl optionally substituted with one or more halogen; each R is independently hydrogen or C 1-4 alkyl optionally substituted with one or more halogen; R A2 is -Cl, -Br, -I, -CN, -C N 2, -N 2, -OR, -C R, -N 3, C 1-4 alkyl with no branching at the benzylic position and optionally substituted with one or more halogen, or an optionally substituted 5- or 6-membered heterocyclyl or heteroaryl having one or two heteroatoms independently selected from nitrogen, oxygen or sulfur; n is 1 to 4; R A3 is -H or -F; R A4 is -F or -OR; R A5 is -OR or -N 2; R 3 is -C N(R 3a) 2, -OR 3b, -C H, -C OR, or -N(R 3c) 2; each R 3a is independently hydrogen or C 1 alkyl optionally substituted with one or more groups independently selected from halogen or 1-pyrrolidinyl; R 3b is hydrogen or C 1-4 alkyl optionally substituted with one or more groups independently selected from halogen, C 1-4 alkyl, C 1-4 haloalkyl, oxo, or -N 2; each R 3c is independently hydrogen or C 1-4 alkyl optionally substituted with one or more groups independently selected from halogen, C 1-4 alkyl, C 1-4 haloalkyl, oxo, or -N 2; R 4 is R or halogen; and R 5 is hydrogen, methyl or -N 2;