Rstudio Error: Unable to establish connection with R session

My problem is i have been able to use rstudio to write code for a long time. However, recently, when i start my rstudio, no matter which button i click or whatever I do, this "Error: Unable to establish connection with R session" pop up. When I tried to edit files, it shows up. When I tried to run code, it shows up. I couldn't remove plots. I could not do anything with Rstudio now. This is being a problem.

I uninstalled rstudio and then reinstall. The same problem still persists.

Please help. It's been a few days that this has been happening already. I really need a fix on this.


Below are the methods I have tried and the "Unable to establish connection with R sessino" still would not go away.

  1. Resetting the Rstudio desktop by removing the entire folder.

  2. Remove start-up files.Rdata , .Rprofile and .Rhistory and

  3. Changing software rendering to "Software"

  4. Uninstall R and RStudio and reinstall again.

I have attached my SessionInfo() below.

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

[1] LC_COLLATE=English_Hong Kong SAR.1252  LC_CTYPE=English_Hong Kong SAR.1252    LC_MONETARY=English_Hong Kong SAR.1252
[4] LC_NUMERIC=C                           LC_TIME=English_Hong Kong SAR.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3      lattice_0.20-38 zoo_1.8-6       digest_0.6.23   later_1.0.0     mime_0.9        grid_3.6.3     
 [8] R6_2.4.1        xtable_1.8-4    magrittr_1.5    rlang_0.4.2     promises_1.1.0  tools_3.6.3     shiny_1.4.0.2  
[15] httpuv_1.5.2    fastmap_1.0.1   compiler_3.6.3  htmltools_0.4.0

None of the above works for me.

Can RStudio please look into it please ? I am working on my master thesis and the deadline is coming up.

:pleading_face: :pleading_face: :pleading_face: :pleading_face: :pleading_face: :pleading_face: :pleading_face:


Just notice that every time I started my RStudio, It reopened the multiple browser() windows (for debugging) that was closed previously.

# ERROR: Definition of function 'testing' not found
# in namespace '.GlobalEnv'
1 Like

Try reseting RStudio's state

I tried renaming the Rstudio-Desktop folder as well as the "other preferences" folder. With a fresh rstudio desktop, It still crashed and the same error message popped up, no matter what i click.

Have you tried changing to software rendering?, you can change it by holding the Ctrl key while opening RStudio, then you should see this menu and change the "Rendering Engine" to "Software".

Also double check that your file doesn't have something that could be causing the crash

Yes. I tried rendering engine to software too. Still crashing. Where do I find my file and how do i check that it does not have anything that could lead to crashing ?

The file is located on your installation folder, something like this C:\Program Files\R\R-3.6.3\etc\
This contains R commands so check if there is something that could be causing a crash if nothing has modified this file all lines should be commented.

So i located my file, which is shown below. All lines are commented except the options(help_type="html")

# Things you might want to change

# options(papersize="a4")
# options(editor="notepad")
# options(pager="internal")

# set the default help type
# options(help_type="text")

# set a site library
# <- file.path(chartr("\\", "/", R.home()), "site-library")

# set a CRAN mirror
# local({r <- getOption("repos")
#       r["CRAN"] <- "http://my.local.cran"
#       options(repos=r)})

# Give a fortune cookie, but only to interactive sessions
# (This would need the fortunes package to be installed.)
#  if (interactive()) 
#    fortunes::fortune()

I'm out of ideas, you are going to have to wait for RStudio people to weigh in.

still grateful with ur help. Thx a lot :slight_smile:

I have one last idea, check that you don't have any .Rdata file in your default working directory.

Well, there is only one .Rhistory file. That's all.

My fellow students and I confront this problem as well recently and don't know how to solve it.

I have never experienced this before. The error message just pops up every 10 seconds. Glad that we are on the same boat. Let's wish that they will help us fix it. :slight_smile:

Hi Tom,

We've had limited reports of this before. In one instance, it was resolved by disabling the anti-virus software (avast):

Do you have AV running that you can disable as a test?
Does the same problem occur if you run RStudio as an administrator?

Another reported issue self resolved:
There it was suggested to try the dailies:
The preview version is also available here: RStudio Preview - RStudio

If none of the above helps, we encourage you to file a new issue here:

Kind regards!

Thanks for reaching out. I do not have avast or anti virus software installed on my machine.

Several thing that caught my eyes are that (1) whenever the R script tries to autosave, I got the "Unable to establish connection with R session" message which is "Error in Saving File". (2) Everytime I restart R, it reopens multiple browser windows that was closed previously. And it generated an error message saying function not found in namespace .GlobalEnv. Something is corrupted but I do not know what.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.