The Force can be used from very far away
The Force can be used at a considerable distance, both for communication and for attack.
It is possible to Force Choke someone from far away. Darth Vader famously choked Admiral Ozzel from another ship after the latter “failed him for the last time.”1
More notably, in “The Lost One,” Darth Sidious choked Count Dooku from Coruscant while the latter was on Serenno:
Mother Talzin was able to use Nightsister magick, drawn from the Dark Side, to torture Dooku from a distance.2 She is on Dathomir and he is on Serenno. To do this, she needed a lock of his hair.
Darth Sidious and Darth Tyranus tried to influence or otherwise mentally attack Yoda when the latter was on the Sith world of Moraband,3 and the former two on Coruscant. This also required a connection to Yoda (don’t forget, Sidious studied with Talzin in his youth!)
SIDIOUS: Only the presence of someone significant to you would allow you to
sense this ripple through time and space.
DOOKU: My old master Yoda.
Master Yoda has come to Moraband, although why, I do not know. We
shall, however, use the strong bond that once existed between you and
your master to allow us to see things that we otherwise could not.
While they certainly use it to see Yoda, they also mount a mental attack on him, making him see illusions, with the apparent goal of corrupting or breaking him:
SIDIOUS: We have failed to break Master Yoda. He is strong. We will need more
time if we are to defeat him and the Jedi.
Finally, Sidious was able to attack Ezra and Ahsoka with some sort of Sith flame sorcery while the latter were on Lothal (kind of?) and the former was, presumably, on Coruscant.
Yoda was able to send visions to Ezra, Ahsoka, and Kanan when they were in the Lothal Jedi Temple.4 As mentioned on Rebels Recon:
Ultimately, the visions created in the Temple are a means of
communication for Yoda to instruct and teach these young Jedi. The
vision of the Grand Inquisitor is entirely motivated by Yoda, who’s
basically letting Kanan know that he is a Jedi Knight.
He, presumably, is on Dagobah, so he is communicating over a considerable distance.
Luke was able to communicate with Leia over a distance. From the script for The Empire Strikes Back.
LUKE: Hear me! Leia!
INT. MILLENNIUM FALCON - COCKPIT
Leia seems to be lost in a fog, her expression troubled. Chewie is
busy operating the ship. Lando stands next to the Wookiee, watching a
readout on the control panel.
LEIA: Luke… We’ve got to go back.
Luke was able to provide a semi-physical projection of himself in The Last Jedi, which could leave portions of itself behind in a solid form (the dice) or be incorporeal save for visibility and audibility (his fight with Kylo).
Snoke was able to link together the minds of Rey and Kylo (at least, he claimed it was his doing), a bond that was not dependent on its creator. This bond also allowed for some incidental substance transmission (e.g. rain). Of course, not one but three powerful Force users were involved in this.
So it’s clear that the Force does not require close physical proximity, or even necessarily line of sight.
However, it is still limited by distance
None of the previous examples should be construed as implying that distance is irrelevant when it comes to the Force, however. These are rare instances, and the people involved are more powerful than the average force wielder. Palpatine, for example, is the most powerful Sith Lord met thus far, with powers significantly in excess of Count Dooku’s. Besides Palpatine and Vader, we have not seen any other Force user in canon employ Force telekinesis on any kind outside of their immediate proximity, and only Palpatine over such a distance—a rather strong indication that this is not a common talent.
It seems clear that Force choking someone from afar is the mark of a very powerful Force wielder. Mother Talzin is no hack either, having gone toe-to-toe with Mace Windu.5 Even Sidious sought out her knowledge in his youth.6 For Force wielders less skilled than Talzin, Sidious, or Vader, attacking someone with the Force from afar might well be impossible. It seems likely that it is more difficult to affect someone nearby, though, even for those capable of doing so. In Sidious and Vader’s cases, it also seems to require line of sight (or perhaps merely precise knowledge of someone’s location), whereas using the Force on those nearby does not require this (as illustrated by Barriss Offee7 and Darth Sidious’s8 examples).
In the case of communication, the only instance of interstellar Force communication that we know of for sure involved the Jedi Temple as a conduit. It is possible that even Yoda could not communicate over such a distance without that aid: even likely, considering that he had not contacted the rebels before.
So distance still matters.
1: The Empire Strikes Back
2: The Clone Wars: “Massacre”
3: The Clone Wars: “Sacrifice”
4: Rebels: “Shroud of Darkness”
5: The Clone Wars: “The Disappeared”
6: Son of Dathomir, Part III
7: The Clone Wars: “The Lawless”
8: The Clone Wars: “The Jedi Who Knew Too Much”