"There is a village by the river."
This is just one resource, but I've seen similar info elsewhere: https://crunchynihongo.com/differentiate-tonari-yoko-soba-chikaku/
- 側 （そば）is accepted,
- 近く（ちかく）should probably be accepted if it isn't already,
- 隣 （となり）should likely not be accepted, and,
- 横 （よこ）might also be inappropriate, but it depends a bit on interpretation of the sentence.
隣（となり）is typically reserved for comparing things of the same "type". E.g. People to people, buildings to buildings, etc. And as such, wouldn't normally be used here to contrast a village and a river. Additionally, the sentence doesn't imply the village directly "borders" the river just that it's "by the river" (but it's ambiguous in English) (see footnote)
横（よこ）is similar, meaning "beside" but it doesn't imply a "type" similarity like 隣. Though it does imply orientation (see footnote). It's difficult to tell whether it would be inappropriate or not; looking at examples online though, I think it would be uncommon to use it like this.
側（そば）(usually written with just hiragana) means something is "nearby". It doesn't care if you compare unlike things, it doesn't care about vertical or horizontal orientation, and they don't need to be precisely neighbouring (other things can be in-between). This is probably why it's the accepted answer.
I haven't checked recently, but I had 近くに（ちかくに）rejected prior; but it is also just concerned with something being "near / in the vicinity", and AFAIK it should also be fine. Example sentences on Jisho seem really similar to this one: https://jisho.org/search/%E8%BF%91%E3%81%8F%E3%81%AB%20%23sentences E.g. 川の近くにテントを張った "We put up a tent near the river"
Both 隣 and 横 seem to imply a specific arrangement of the objects, from most of the sources I'm looking at. Particularly 横, as other meanings of the term are literally "horizontal, width, [the] side [of something]".
- 隣 - Neighbouring; distance separating the things doesn't matter, but another instance of the same things can't be in-between. Can be vertical or horizontal. Can only be used to compare like "type" things, people to people, towns to towns, buildings to buildings.
E.g. Two countries are 隣 even if separated by oceans. Japan is 隣 to Korea, but Canada is not 隣 to Mexico, because the USA is also a country & it's in-between.
- 横 - Aligned horizontally. Distance doesn't seem to matter. I think things can be in-between; seems to usually mean "directly beside" though. Can be used to compare dissimilar types of things: 野球場の横の道（やきゅうじょうのよこのみち）"the road beside the baseball stadium"
I'm sort of surprised that Duo doesn't accept 近く（ちかく）in place of 側（そば）. I'm reporting it given various resources I've read, but is there any reason why they wouldn't that I'm not aware of? http://crunchynihongo.com/differentiate-tonari-yoko-soba-chikaku/
Edit: Nah, see my other comment on this thread. Almost positive 「川の近くに村があります」should be accepted if it's not now, based on similar sentences & resources I've seen elsewhere.