shiny server refused connection despite port 3838 open

I have launched a shiny app on a new server hosted on AWS.

rstudio is accessible on the server through the IP address but the app is not accessible through the 3838 port. I have checked the port 3838 is open for the security group of the EC2 instance in AWS.
One rstusio user faced the same problem but the problem was resolved by opening port 3838 in Inbound rules. I have it open anyways. I also tried to open an incognito browser tab assuming cookies may be interfering... no luck.

Does anyone has any other suggestions?


Here are the screenshots showing port 3838 open and the error in the chrome browser

Have you checked the status of the shiny-server service? Is it currently listening on port 3838? Do you have any firewall installed on the EC2 instance itself?

This issue is very specific to your particular setup so it is going to be hard for outside people to help you. If you can get help from within your organization (with proper access to your AWS infrastructure) that would be ideal.

Yes indeed I confirm that it is listening to 3838.
Meanwhile I launched a brand new instance of AW EC2 with the original image of Rstudio (note: I use a pre existing AMI with R and Rstudio)
Without modifying any defaults, here is the server config:

rstudio@ip-172-31-2-247:/srv/shiny-server$ cd /etc/shiny-server/
rstudio@ip-172-31-2-247:/etc/shiny-server$ ls
rstudio@ip-172-31-2-247:/etc/shiny-server$ cat shiny-server.conf 
run_as shiny;
server {
  listen 3838;
  run_as :HOME_USER:;
  location / {

And here is the confirmation that the shiny server is ON. The access to 3838 is still denied.

rstudio@ip-172-31-2-247:/srv/shiny-server$ sudo systemctl status shiny-server
[sudo] password for rstudio: 
● shiny-server.service - ShinyServer
   Loaded: loaded (/etc/systemd/system/shiny-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2021-12-19 17:35:48 UTC; 27min ago
 Main PID: 894 (shiny-server)
    Tasks: 11 (limit: 4671)
   CGroup: /system.slice/shiny-server.service
           └─894 /opt/shiny-server/ext/node/bin/shiny-server /opt/shiny-server/lib/main.js

Dec 19 17:35:48 ip-172-31-2-247 systemd[1]: Started ShinyServer.

Maybe it's related to the reverse proxy you are using, can you show your config?

I don't think the AWS EC2 has a reverse proxy. I have launched a fresh instance too. Moreover the fact I can access the rstudio loaded on the same server does mean the server is allowing access. It seems either the port 3838 is inaccessible or shiny server is rejecting the input attempt.
Here is the screenshot of the security group configurd on AWS.

And here is the shiny R config file contents.

I also paste the shiny server directory listing.

rstudio@ip-172-31-2-247:/srv/shiny-server$ ls -l /srv/shiny-server/
total 0
lrwxrwxrwx 1 root root 38 Aug 16  2020 index.html -> /opt/shiny-server/samples/welcome.html
lrwxrwxrwx 1 root root 37 Aug 16  2020 sample-apps -> /opt/shiny-server/samples/sample-apps

Ideally since there is an index.html the url should directly open the html file there.

What else should I check?

Thanks for pursuing.


Since you can reach RStudio server on port 80, where the default is 8787, I assumed you were using a reverse proxy, maybe you just changed the listening port for RStudio.

Most likely this issue is not on the shiny-server side of things but with your EC2 instance configuration, have you checked that you don't have a firewall (like ufw or firewalld) rule blocking traffic? Or have you tried configuring a reverse proxy to avoid using the 3838 port? you could use server_ip/shiny/ to bypass traffic over port 80 which you know for sure is open.

Hi @andresrcs
The firwall ufw is inactive.

rstudio@ip-172-31-2-247:/opt/shiny-server/config$ sudo ufw status verbose
[sudo] password for rstudio: 
Status: inactive

I can tell you I have launched atleast a dozen shiny servers on AWS and faced "connection refused" error several times and it was most often resolved by config settings in the AWS EC2 security group (which is the virtual firewall). This time I am unable to find what that problem could be. I also tried exclusive 3838 port opening as well as all ports opening. Even after opening "All Traffic" on "All ports" from "All IP addresses" nothing seems to work.

I have another shinyapp working on another EC2 instance and it opens the default app successfully.

I cleared my browser cache and even changed the browser to Safari (from chrome) but no luck.

As the port 80 is open (I can access rstudio console) there seems to be some portr config that is missing somewhere. Would appreciate if you could suggest a step by step diagnosis for error connection refused.

Note: This is a very common error encountered by many people (as I see stackoverflow) and is the starting problem almost everytime I start a new shiny server. Creation of an exhaustive checklist for this problem diagnosis will be really nice.

I have never used a pre-installed AMI for RStudio products so I have no idea what configuration they might preset that could be causing this problem. I always use a clean Ubuntu Server LTS AMI and install everything I need myself (automated with Ansible) and I have never encountered such a problem. Maybe if you specify which AMI you are using someone else might be able to help.

I use the AMI published here:
Now it could be that the image itself has some peculiar settings that we are unaware of.
I was wondering why rstudio does not publish AMIs, so we donot have to go for a fresh instal and fresh configs. Shiny configs could be tricky on a fresh server.

If no one is able to diagnose my issue I guess my best next action would be to stop this instance and bring up another ubuntu 18 instance with a blank volume and install rstudio and shiny from scratch. I will look up Ansible too and report back on this thread. Thank for staying with me @andresrcs .

Just found out ansible requires python to be installed in the local machine. Seems it is a longer process to learn to use ansible than directly installing r, rstudio and shiny on the new Ubuntu Ec2 instance.

1 Like

They do have AWS AMIs for their professional products but maintaining AMIs for their open source software won't make much sense for their business model.

If you keep default settings is pretty straight forward actually

I would recommend going for the latest LTS version 20.04

You could follow this blog post I wrote, it is actually pretty simple to do.

1 Like

BTW the AMI description sais

Shiny at /shiny/rstudio

So it seems you do have a reverse proxy and the 3838 port blocked by a firewall (not AWS security rules but a firewall installed in the server itself).

I would strongly recommend installing your own server because it seems the AMI's setup is very opinionated.


Many thanks @andresrcs for the insightful answers. I will read the blog you wrote and attempt the entire installation and migrating my files to a new server. And I will use Ubuntu 20 as you suggest.

1 Like

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.