Random port while using runApp

I have installed R Shiny server on Ubuntu 18.04.3 LTS (GNU/Linux 5.0.0-1025-azure x86_64) and also RStudio. I have allowed on shiny server config file the Host Per-User Application Directories, and it works well when I test using http://:3838//hello/. When I run the app from RStudio on the same server using

runApp("ShinyApps/hello/", launch.browser = T , port = 5050)

with a specific port the app launches with a random port, http://:8787/p/52daa6b8/. When I share the url , it returns Connection refused.

Sorry for the delay here. I believe what you are talking about is mixing up the roles of RStudio Server and Shiny Server.

RStudio Server allows you to interactively run R code and preview Shiny applications in your development environment. It typically listens on port 8787, but does not allow sharing arbitrary URLs with others (as they are within your "user" / dev space).

Shiny Server, on the other hand, is one method of "sharing" Shiny applications. Other methods include shinyapps.io, RStudio Connect, or running the Shiny application on a given port (as you show) and then generating the firewall / link to share yourself (i.e. localhost:5050).

Shiny Server is configured separately from RStudio Server and typically listens on a different port (3838 by default). As you mentioned, you can share "per user application directories" at a location like http://:3838/username/myapp

I hope that helps!