R: Unable to establish connection with R session

I was using the latest versions of both R and RStudio on Mac (Big Sur). I was trying to install a package that I don't currently remember the name of, and RStudio suddenly give the following error: "Unable to establish connection with R session". I checked the previous posts but as far as I could implement the suggestions over there, they failed to make it work. What should I do?