RStudio "Cannot Connect to R"

I have installed the latest R (4.1.2) and RStudio (2021.09.2+382). However, when RStudio launches it cannot connect the IDE.

We've also tried our standard packaged install of R (4.0.2) and RStudio (1.3.1056), with the same issue.

This installation is on a Windows 10 RDP connected host. But from what I can gather it looks like the port isn't even listening.

If I "inspect element" on the application window after it loads I can see that the retry button is trying to access port 15670 (http://127.0.0.1:15670/).

But if I run a netstat -ab that port isn't open and listening. If I run the same command on a working laptop there are "rsession.exe" threads running on the port that it has launched with.

Here are a few outputs from the affected machine:
> Sys.which("R") R "C:\\PROGRA~1\\R\\bin\\x64\\R.exe"

The "rdesktop.log" in %localappdata%\RStudio\log has this message:
2022-02-03T03:57:04.727340Z [rdesktop] ERROR Main window closed unexpectedly; LOGGED FROM: auto __cdecl rstudio::desktop::MainWindow::closeEvent::<lambda_6df4003a5993ea0cdb87988cf8be933c>::operator ()(class QVariant) const src/cpp/desktop/DesktopMainWindow.cpp:524

There is also a "rsession-username.log" file in the same directory that has this message:
2022-02-03T05:26:37.547632Z [rsession-username] ERROR Unable to retrieve user home path. HRESULT: -2147024893; LOGGED FROM: class rstudio::core::FilePath __cdecl rstudio::core::system::userSettingsPath(const class rstudio::core::FilePath &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,bool) src/cpp/core/system/Win32System.cpp:338

I have also tried to follow the other steps to confirm AV isn't getting involved etc and clear any R Directories to reset any settings.

I've been informed we've run RStudio on RDP sessions before. But I'm running out of things to look into as to why it isn't running at the moment.

Any suggestions of additional things to try or investigate would be great.

Thanks,
Ryan

Here is a dump of the diagnostics report:

RStudio Diagnostics Report
==========================

WARNING: This report may contain sensitive security information and / or
personally identifiable information. Please audit the below and redact any
sensitive information before submitting your diagnostics report.

Generated: Thu Feb 03 15:48:03 2022

RStudio Version
--------------------------------------------------
2021.09.2+382


Session Information
--------------------------------------------------
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252   
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    
system code page: 65001

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

loaded via a namespace (and not attached):
[1] compiler_4.1.2 tools_4.1.2   


System Information
--------------------------------------------------
sysname        : Windows       
release        : Server x64    
version        : build 19042   
nodename       : COMPUTERNAME
machine        : x86-64        
login          : username        
user           : username        
effective_user : username        


Platform Information
--------------------------------------------------
OS.type    : windows
file.sep   : /
dynlib.ext : .dll
GUI        : Rgui
endian     : little
pkgType    : win.binary
path.sep   : ;
r_arch     : x64


Environment Variables
--------------------------------------------------
ALLUSERSPROFILE                 : C:\ProgramData
APPDATA                         : C:\Users\username.domain\AppData\Roaming
CLICOLOR_FORCE                  : 1
CLIENTNAME                      : CLIENT_COMPUTER
CommonProgramFiles              : C:\Program Files\Common Files
CommonProgramFiles(x86)         : C:\Program Files (x86)\Common Files
CommonProgramW6432              : C:\Program Files\Common Files
COMPUTERNAME                    : COMPUTERNAME
ComSpec                         : C:\Windows\system32\cmd.exe
DriverData                      : C:\Windows\System32\Drivers\DriverData
GFORTRAN_STDERR_UNIT            : -1
GFORTRAN_STDOUT_UNIT            : -1
HOME                            : C:/Users/username.domain/Documents
HOMEDRIVE                       : C:
HOMEPATH                        : \Users\username.domain
LOCALAPPDATA                    : C:\Users\username.domain\AppData\Local
LOGONSERVER                     : \\DC
MONITORING_CONFIG_VERSION       : 1.29
MONITORING_DATA_DIRECTORY       : C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Monitoring
MONITORING_ENV                  : PROD
MONITORING_GCS_ACCOUNT          : RDSAgentProd
MONITORING_GCS_AUTH_ID          : *** redacted ***
MONITORING_GCS_AUTH_ID_TYPE     : *** redacted ***
MONITORING_GCS_CERTSTORE        : LOCAL_MACHINE\MY
MONITORING_GCS_ENVIRONMENT      : Diagnostics Prod
MONITORING_GCS_NAMESPACE        : RDSAgentProd
MONITORING_GCS_REGION           : eastus2
MONITORING_MDM_ACCOUNT          : RDSAgentProd
MONITORING_RESOURCE             : CONTROLLER
MONITORING_ROLE                 : Dedicated_hostpool
MONITORING_ROLE_INSTANCE        : COMPUTERNAME.domain.com.au
MONITORING_TENANT               : PROD
MSYS2_ENV_CONV_EXCL             : R_ARCH
NUMBER_OF_PROCESSORS            : 4
OneDrive                        : C:\Users\username.domain\OneDrive - domain
OneDriveCommercial              : C:\Users\username.domain\OneDrive - domain
OneDriveSync                    : C:\Users\username.domain\OneDrive - domain
OS                              : Windows_NT
PATH                            : C:\Program Files\R\bin\x64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Azure Data Studio\bin;C:\Program Files\PuTTY\;C:\Program Files\Microsoft VS Code\bin;C:\Users\username.domain\AppData\Local\Microsoft\WindowsApps;
PATHEXT                         : .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE          : AMD64
PROCESSOR_IDENTIFIER            : AMD64 Family 23 Model 49 Stepping 0, AuthenticAMD
PROCESSOR_LEVEL                 : 23
PROCESSOR_REVISION              : 3100
ProgramData                     : C:\ProgramData
ProgramFiles                    : C:\Program Files
ProgramFiles(x86)               : C:\Program Files (x86)
ProgramW6432                    : C:\Program Files
PROMPT                          : $P$G
PSModulePath                    : C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\
PUBLIC                          : C:\Users\Public
PYTHONIOENCODING                : utf-8
QT_D3DCREATE_MULTITHREADED      : 1
R_ARCH                          : /x64
R_COMPILED_BY                   : gcc 8.3.0
R_DOC_DIR                       : C:/PROGRA~1/R/doc
R_HOME                          : C:/PROGRA~1/R
R_LIBS_USER                     : C:/Users/username.domain/Documents/R/win-library/4.1
R_USER                          : C:/Users/username.domain/Documents
RMARKDOWN_MATHJAX_PATH          : C:/Program Files/RStudio/resources/mathjax-27
RS_LOCAL_PEER                   : \\.\pipe\26863-rsession
RS_RPOSTBACK_PATH               : C:/Program Files/RStudio/bin/rpostback
RS_SHARED_SECRET                : *** redacted ***
RSTUDIO                         : 1
RSTUDIO_CONSOLE_COLOR           : 256
RSTUDIO_CONSOLE_WIDTH           : 80
RSTUDIO_MSYS_SSH                : C:/Program Files/RStudio/bin/msys-ssh-1000-18
RSTUDIO_PANDOC                  : C:/Program Files/RStudio/bin/pandoc
RSTUDIO_PROGRAM_MODE            : desktop
RSTUDIO_SESSION_PORT            : 26863
RSTUDIO_USER_IDENTITY           : username
RSTUDIO_WINUTILS                : C:/Program Files/RStudio/bin/winutils
SESSIONNAME                     : rdp-sxs211115500#0
SNC_LIB                         : C:\Program Files (x86)\SAP\FrontEnd\SecureLogin\lib\sapcrypto.dll
SNC_LIB_64                      : C:\Program Files\SAP\FrontEnd\SecureLogin\lib\sapcrypto.dll
SSF_LIBRARY_PATH                : C:\Program Files (x86)\SAP\FrontEnd\SecureLogin\lib\sapcrypto.dll
SSF_LIBRARY_PATH_64             : C:\Program Files\SAP\FrontEnd\SecureLogin\lib\sapcrypto.dll
SystemDrive                     : C:
SystemRoot                      : C:\Windows
TEMP                            : C:\Users\username~1.TRE\AppData\Local\Temp
TERM                            : xterm-256color
TMP                             : C:\Users\username~1.TRE\AppData\Local\Temp
UATDATA                         : C:\Windows\CCM\UATData\D9F8C395-CAB8-491d-B8AC-179A1FE1BE77
USERDNSDOMAIN                   : domain.com.au
USERDOMAIN                      : domain
USERDOMAIN_ROAMINGPROFILE       : domain
USERNAME                        : *** redacted ***
USERPROFILE                     : C:\Users\username.domain
windir                          : C:\Windows
WVD_AGENT_CLUSTER               : CUSR0C101
WVD_AGENT_RING                  : R0
WVD_MONITORING_CONFIG_VERSION   : 1.29
WVD_MONITORING_DATA_DIRECTORY   : C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Monitoring
WVD_MONITORING_ENV              : PROD
WVD_MONITORING_GCS_ACCOUNT      : RDSAgentProd
WVD_MONITORING_GCS_AUTH_ID      : *** redacted ***
WVD_MONITORING_GCS_AUTH_ID_TYPE : *** redacted ***
WVD_MONITORING_GCS_CERTSTORE    : LOCAL_MACHINE\MY
WVD_MONITORING_GCS_ENVIRONMENT  : Diagnostics Prod
WVD_MONITORING_GCS_NAMESPACE    : RDSAgentProd
WVD_MONITORING_GCS_REGION       : eastus2
WVD_MONITORING_MDM_ACCOUNT      : RDSAgentProd
WVD_MONITORING_RESOURCE         : CONTROLLER
WVD_MONITORING_ROLE             : Dedicated_hostpool
WVD_MONITORING_ROLE_INSTANCE    : COMPUTERNAME.domain.com.au
WVD_MONITORING_TENANT           : PROD


R Version
--------------------------------------------------
platform       : x86_64-w64-mingw32
arch           : x86_64
os             : mingw32
system         : x86_64, mingw32
status         : 
major          : 4
minor          : 1.2
year           : 2021
month          : 11
day            : 01
svn rev        : 81115
language       : R
version.string : R version 4.1.2 (2021-11-01)
nickname       : Bird Hippie


R Home
--------------------------------------------------
C:/PROGRA~1/R


R Search Path
--------------------------------------------------
.GlobalEnv       
tools:rstudio    
package:stats    
package:graphics 
package:grDevices
package:utils    
package:datasets 
package:methods  
Autoloads        
package:base     


R Library Paths
--------------------------------------------------
C:/Program Files/R/library


Loaded Packages
--------------------------------------------------
base      : C:/PROGRA~1/R/library/base          
compiler  : C:/Program Files/R/library/compiler 
datasets  : C:/Program Files/R/library/datasets 
graphics  : C:/Program Files/R/library/graphics 
grDevices : C:/Program Files/R/library/grDevices
methods   : C:/Program Files/R/library/methods  
stats     : C:/Program Files/R/library/stats    
tools     : C:/Program Files/R/library/tools    
utils     : C:/Program Files/R/library/utils    


Installed Packages
--------------------------------------------------
        Package                    LibPath Version
1          base C:/Program Files/R/library   4.1.2
2          boot C:/Program Files/R/library  1.3-28
3         class C:/Program Files/R/library  7.3-19
4       cluster C:/Program Files/R/library   2.1.2
5     codetools C:/Program Files/R/library  0.2-18
6      compiler C:/Program Files/R/library   4.1.2
7      datasets C:/Program Files/R/library   4.1.2
8       foreign C:/Program Files/R/library  0.8-81
9      graphics C:/Program Files/R/library   4.1.2
10    grDevices C:/Program Files/R/library   4.1.2
11         grid C:/Program Files/R/library   4.1.2
12   KernSmooth C:/Program Files/R/library 2.23-20
13      lattice C:/Program Files/R/library 0.20-45
14         MASS C:/Program Files/R/library  7.3-54
15       Matrix C:/Program Files/R/library   1.3-4
16      methods C:/Program Files/R/library   4.1.2
17         mgcv C:/Program Files/R/library  1.8-38
18         nlme C:/Program Files/R/library 3.1-153
19         nnet C:/Program Files/R/library  7.3-16
20     parallel C:/Program Files/R/library   4.1.2
21        rpart C:/Program Files/R/library  4.1-15
22      spatial C:/Program Files/R/library  7.3-14
23      splines C:/Program Files/R/library   4.1.2
24        stats C:/Program Files/R/library   4.1.2
25       stats4 C:/Program Files/R/library   4.1.2
26     survival C:/Program Files/R/library  3.2-13
27        tcltk C:/Program Files/R/library   4.1.2
28        tools C:/Program Files/R/library   4.1.2
29 translations C:/Program Files/R/library   4.1.2
30        utils C:/Program Files/R/library   4.1.2


R System Profile: C:/PROGRA~1/R/library/base/R/Rprofile
--------------------------------------------------
### This is the system Rprofile file. It is always run on startup.
### Additional commands can be placed in site or user Rprofile files
### (see ?Rprofile).

### Copyright (C) 1995-2020 The R Core Team

### Notice that it is a bad idea to use this file as a template for
### personal startup files, since things will be executed twice and in
### the wrong environment (user profiles are run in .GlobalEnv).

.GlobalEnv <- globalenv()
attach(NULL, name = "Autoloads")
.AutoloadEnv <- as.environment(2)
assign(".Autoloaded", NULL, envir = .AutoloadEnv)
T <- TRUE
F <- FALSE
R.version <- structure(R.Version(), class = "simple.list")
version <- R.version            # for S compatibility

## for backwards compatibility only
R.version.string <- R.version$version.string

## NOTA BENE: options() for non-base package functionality are in places like
##            --------- ../utils/R/zzz.R

options(keep.source = interactive())
options(warn = 0)
# options(repos = c(CRAN="@CRAN@"))
# options(BIOC = "http://www.bioconductor.org")

## setting from an env variable added in 4.0.2
local({to <- as.integer(Sys.getenv("R_DEFAULT_INTERNET_TIMEOUT", 60))
    if (is.na(to) || to <= 0) to <- 60L
    options(timeout = to)
})
options(encoding = "native.enc")
options(show.error.messages = TRUE)
## keep in sync with PrintDefaults() in  ../../main/print.c :
options(scipen = 0)
options(max.print = 99999)# max. #{entries} in internal printMatrix()
options(add.smooth = TRUE)# currently only used in 'plot.lm'

if(isFALSE(as.logical(Sys.getenv("_R_OPTIONS_STRINGS_AS_FACTORS_",
                                 "FALSE")))) {
    options(stringsAsFactors = FALSE)
} else {
    options(stringsAsFactors = TRUE)
}

if(!interactive() && is.null(getOption("showErrorCalls")))
    options(showErrorCalls = TRUE)

local({dp <- Sys.getenv("R_DEFAULT_PACKAGES")
       if(identical(dp, "")) ## it fact methods is done first
           dp <- c("datasets", "utils", "grDevices", "graphics",
                   "stats", "methods")
       else if(identical(dp, "NULL")) dp <- character(0)
       else dp <- strsplit(dp, ",")[[1]]
       dp <- sub("[[:blank:]]*([[:alnum:]]+)", "\\1", dp) # strip whitespace
       options(defaultPackages = dp)
    })

## Expand R_LIBS_* environment variables.
Sys.setenv(R_LIBS_SITE =
           .expand_R_libs_env_var(Sys.getenv("R_LIBS_SITE")))
Sys.setenv(R_LIBS_USER =
           .expand_R_libs_env_var(Sys.getenv("R_LIBS_USER")))

local({
    if(nzchar(tl <- Sys.getenv("R_SESSION_TIME_LIMIT_CPU")))
        setSessionTimeLimit(cpu = tl)
    if(nzchar(tl <- Sys.getenv("R_SESSION_TIME_LIMIT_ELAPSED")))
        setSessionTimeLimit(elapsed = tl)
})

.First.sys <- function()
{
    for(pkg in getOption("defaultPackages")) {
        res <- require(pkg, quietly = TRUE, warn.conflicts = FALSE,
                       character.only = TRUE)
        if(!res)
            warning(gettextf('package %s in options("defaultPackages") was not found', sQuote(pkg)),
                    call. = FALSE, domain = NA)
    }
}

## called at C level in the startup process prior to .First.sys
.OptRequireMethods <- function()
{
    pkg <- "methods" # done this way to avoid R CMD check warning
    if(pkg %in% getOption("defaultPackages"))
        if(!require(pkg, quietly = TRUE, warn.conflicts = FALSE,
                    character.only = TRUE))
            warning('package "methods" in options("defaultPackages") was not found',
                    call. = FALSE)
}

if(nzchar(Sys.getenv("R_BATCH"))) {
    .Last.sys <- function()
    {
        cat("> proc.time()\n")
        print(proc.time())
    }
    ## avoid passing on to spawned R processes
    ## A system has been reported without Sys.unsetenv, so try this
    try(Sys.setenv(R_BATCH=""))
}

local({
    if(nzchar(rv <- Sys.getenv("_R_RNG_VERSION_")))
        suppressWarnings(RNGversion(rv))
})

.sys.timezone <- NA_character_
.First <- NULL
.Last <- NULL
###-*- R -*-

## this will break if R is on a network share
.Library <- file.path(chartr("\\", "/", R.home()), "library")
.Library.site <- Sys.getenv("R_LIBS_SITE")
.Library.site <- if(!nzchar(.Library.site)) file.path(R.home(), "site-library") else unlist(strsplit(.Library.site, ";"))
.Library.site <- .Library.site[file.exists(.Library.site)]

if(!nzchar(Sys.getenv("R_LIBS_USER")))
    Sys.setenv(R_LIBS_USER=
               file.path(Sys.getenv("R_USER"), "R",
                         "win-library",
                         paste(R.version$major,
                               sub("\\..*$", "", R.version$minor),
                               sep=".")
                         ))

invisible(.libPaths(c(unlist(strsplit(Sys.getenv("R_LIBS"), ";")),
                      unlist(strsplit(Sys.getenv("R_LIBS_USER"), ";"))
                      )))

local({
    popath <- Sys.getenv("R_TRANSLATIONS", "")
    if(!nzchar(popath)) {
        paths <- file.path(.libPaths(), "translations", "DESCRIPTION")
        popath <- dirname(paths[file.exists(paths)][1])
    }
    bindtextdomain("R", popath)
    bindtextdomain("R-base", popath)
    bindtextdomain("RGui", popath)
    assign(".popath", popath, .BaseNamespaceEnv)
})

if(nzchar(Sys.getenv("R_PAPERSIZE"))) {
    options(papersize = Sys.getenv("R_PAPERSIZE"))
} else {
    if(grepl("(canada|united.states)", Sys.getlocale("LC_MONETARY"),
             ignore.case = TRUE)) options(papersize = "letter")
    else options(papersize = "a4")
}

options(pager = if(length(grep("--ess", commandArgs()))) "console" else "internal",
        useFancyQuotes = (.Platform$GUI == "Rgui"),
        pdfviewer = Sys.getenv("R_PDFVIEWER", file.path(R.home("bin"), "open.exe")))

if(.Platform$GUI == "Rgui")
    Sys.setenv(GFORTRAN_STDOUT_UNIT = "-1", GFORTRAN_STDERR_UNIT = "-1")

local({
    br <- Sys.getenv("R_BROWSER", NA_character_)
    if(!is.na(br)) options(browser = br)
    tests_startup <- Sys.getenv("R_TESTS")
    if(nzchar(tests_startup)) source(tests_startup)
    ca_cert <- Sys.getenv("CURL_CA_BUNDLE", NA_character_)
    if(!is.na(ca_cert) &&
       file.exists(ca_path <- file.path(R.home("etc"), "curl-ca-bundle.crt")))
        Sys.setenv(CURL_CA_BUNDLE = ca_path)
})


R Site Profile: C:/PROGRA~1/R/etc/Rprofile.site
--------------------------------------------------
# Things you might want to change

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

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

# set a site library
# .Library.site <- 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()



R User Profile: C:/Users/username.domain/Documents/.Rprofile
--------------------------------------------------
(File does not exist)


R Site Environ: C:/PROGRA~1/R/etc/Renviron.site
--------------------------------------------------
(File does not exist)


R User Environ: C:/Users/username.domain/Documents/.Renviron
--------------------------------------------------
(File does not exist)


R Temporary Directory
--------------------------------------------------
C:\Users\username~1.TRE\AppData\Local\Temp\Rtmpy8jhjT


Files in R Temporary Directory
--------------------------------------------------
rs-graphics-ba6fbdad-0969-422d-9f85-604aa746c939


Log file: C:/Users/username.domain/AppData/Local/RStudio/log/rdesktop.log
--------------------------------------------------

(Not Found)

Log file: C:/Users/username.domain/AppData/Local/RStudio/log/rsession-username.log
--------------------------------------------------

2022-02-03T05:44:17.945989Z [rsession-username] WARNING FileLock classes not yet initialized; please call 'FileLock::initialize()' and 'FileLock::cleanUp()' as appropriate; LOGGED FROM: bool __cdecl rstudio::core::FileLock::verifyInitialized(void) src/cpp/core/file_lock/FileLock.cpp:113
2022-02-03T05:44:17.950986Z [rsession-username] ERROR system error 39 (The disk is full) [lock-file: C:/Users/username.domain/AppData/Local/RStudio/rs-14-migration.lock]; OCCURRED AT class rstudio::core::Error __cdecl rstudio::core::LinkBasedFileLock::acquire(const class rstudio::core::FilePath &) src/cpp/core/file_lock/LinkBasedFileLock.cpp:447; CAUSED BY: system error 40 (Unknown error (40)); OCCURRED AT class rstudio::core::Error __cdecl rstudio::core::`anonymous-namespace'::writeLockFile(const class rstudio::core::FilePath &) src/cpp/core/file_lock/LinkBasedFileLock.cpp:370; LOGGED FROM: class rstudio::core::ProgramStatus __cdecl rstudio::session::Options::read(int,char *const [],class std::basic_ostream<char,struct std::char_traits<char> > &) src/cpp/session/SessionOptions.cpp:234
2022-02-03T05:48:02.813969Z [rsession-username] ERROR Unable to retrieve user home path. HRESULT:  -2147024893; LOGGED FROM: class rstudio::core::FilePath __cdecl rstudio::core::system::userSettingsPath(const class rstudio::core::FilePath &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,bool) src/cpp/core/system/Win32System.cpp:338


User prefs: C:/Users/username.domain/AppData/Roaming/RStudio/rstudio-prefs.json
--------------------------------------------------

(Not Found)

System prefs: C:/ProgramData/RStudio/rstudio-prefs.json
--------------------------------------------------

(Not Found)

User state: C:/Users/username.domain/AppData/Local/RStudio/rstudio-desktop.json
--------------------------------------------------

{
    "context_id": "D036323D",
    "error_handler_type": "traceback"
}

We have resolved this issue now. It ended up being an agent installed on the RDP Instances for the PaloAlto Firewall "PAN Terminal Server Agent". This agent tracks multiple users logged into a machine and the applications they run for User Based Rules rather than IP Based Rules.

I'm circling back to this one in case it helps someone else troubleshoot or solve the same issue.

We ended up trying to replicate the issue in Python and Powershell to simplify what may be stopping the port.

Python2 Command:

>python -m SimpleHTTPServer 12345 --bind 127.0.0.1

Python3 Command

>python -m http.server 12345 --bind 127.0.0.1

PowerShell Command

$Listener = [System.Net.Sockets.TcpListener]12345;
$Listener.Start();
#Port will be open and available via netstat

What we were seeing is that even when the port was explicitly defined, when we checked via netstat we would see that it was opening on another random port:
Extract of "netstat -anob" command

>netstat -anob
 TCP    0.0.0.0:22736          0.0.0.0:0              LISTENING       22360
 [python.exe]

However on a working PC we found that port did open:

>netstat -anob
 TCP    0.0.0.0:12345          0.0.0.0:0              LISTENING       12764
 [python.exe]

All of the programs - R, rStudio, Python, Powershell etc. Issue the command to open the port on a specified number. It's fired off and probably receives a Success message back, without receiving a confirmation of the actual port that was opened. The assumption is if it was successful, the desired port will be opened.

When we investigated further as to why we found that the PA Agent track users by allocating a small range of ports to each user. When the User opens up a port it redirects that connection to one in the allocated range for that user. Breaking the process of opening a specific port number.

For us these RDP machines are only allocated to one user. So the PA Agent shouldn't have been installed in their environment, but it was pushed out across the whole fleet. Removing the PA Agent sorted our issue.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.