Shiny 2: Installing RStudio Shiny Server on AWS 11

In this beginner’s level tutorial, you’ll learn how to install Shiny Server on an AWS cloud instance, and how to configure the firewall. It will take just a few minutes!

This tutorial is number two in a series of four parts.

  1. Setting up an AWS instance for R.
  2. Installing Shiny Server on AWS (this one)
  3. Shiny https
  4. Shiny password protection


Playing around with Shiny is simple enough: all you need is is the R package called shiny, which you can get directly from CRAN.

Making your work available to you mentor is also straight forward: open an account on, and deploy your application directly from RStudio.

Blogging about your Shiny app is a different story: you might have hundreds of hits in a day, and soon enough your application will hit the max hours available for free on As a result, your app will stop working.

Another situation in which you might want to deploy your own Shiny server is if you need access to a database behind a firewall (see Shiny Crud), or if you want to restrict access to your app to people within your sub net (e.g. within your intranet).


This tutorial builds on the following tutorial: Setting up an AWS instance. So we assume that you have a working AWS EC2 Ubuntu instance with a recent version of R installed.

Other References and Links

Shiny Server Open Source is free, and has extensive documentation. However, getting started is not so easy, as it is not always clear which documents apply to the Pro edition (the commercial offering) and which to the Open Source edition.

The official installation instruction from RStudio, the company behind Shiny, can be found at this link.

And here is a similar guide for digitalocean, a competitor of AWS.

Installing Shiny Server Open Source

This section is not depending on AWS. So I am assuming you have a running Ubuntu instance, and you can access it via ssh. Also, the most recent version of R needs to be installed. If any of this is not the case, see here.

Otherwise, you should see a window like this:

As a first step, we install the R Shiny package. The following command not only installs the package, but also makes sure that it is available for all users on your machine:

This might take a while, as all shiny dependencies are downloaded as well.

Next, you need to install Shiny server itself, by typing the following commands:

You might want to replace the version number of the Shiny Server with the latest available release, as published here. However, leave the ubuntu version (12.04) as is, even if you run on a new version.

When prompted whether you want to install the software package, press y, of course.

Your Shiny server is now installed. But before we can test it, there are two things missing:

  1. we need to install an app
  2. we need to open the port, so your Shiny server can be accessed from the outside world

Install Sample app

To install the sample app that is provided by the Shiny installer, type the following into your console:

Again, type y if prompted.

Configuring Firewall

In order to be able to connect to Shiny Server, you might need to open the port on which Shiny Server listens. By default, this is port 3838.

On AWS, you can open the port by configuring the Security Group of your instance. Go to Instances, select your instance, and then click on the Security Group in the instance’s detail section:

This will bring you to the Security Groups configuration screen. Click on the Inbound tab. By default, AWS instances launched with the wizard have only port 22 open, which is needed to SSH in. No wonder we cannot access our instance!

Click on Edit and add a custom TCP rule to open port 3838 from anywhere, like so:

Open your favorite browser and enter the following address:

Replace the IP address (, in our example) with the public IP address of your instance, which is the same with which you connected to your instance. If everything went fine, you will see something like this:

And that’s it!

Basic Configuration and Administration

Though not the main goal of this post, let’s look at a few basic configuration options.

Start and Stop

To start and stop a Shiny Server, execute these commands:


Shiny is mainly configured via the following file:

 We can use the minimalistic text editor Nano to edit the configuration file. Type

You should see something like this:


For example, you could now change the port to 80, letting your users connect without specifying a port, e.g. like so:

To do that, you need to perform the following steps:

  1. in Nano, change the port from 3838 to 80
  2. Save the file by hitting Ctrl+X and answering Yes
  3. Restart the server by typing
  4. Open your port 80 in the AWS EC2 Security Group by adding a custom TCP rule for port 80, similar to what you did above for 3838


I hope you enjoyed this tutorial. In the next post, we’ll describe how to enable secure https connections in Shiny Server Open Source, and we’ll explain why you would want to do this.


Read Part 3


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

11 thoughts on “Shiny 2: Installing RStudio Shiny Server on AWS

  • Matt Sedlar

    Great post! This is really helping me a lot. One thing to note: Ubuntu, starting with 15.04 and going forward, no longer uses upstart but systemd for init. So the command to start shiny-server would be “sudo systemctl start shiny-server,” etc.

  • Vishwanath Math

    Hi Christoph,

    I have created a webapp using shiny and flexdashboard. I have created an EC2 instance with ubuntu AMI, installed Rstudio server. I am able to login into the rstudio server using the :- public ip address of EC2:8787. When i run the document a dashboard with bar charts and line garphs opens up but when i click on the option “open in browser” the charts dont show up only the flex dashboard layout shows with the headers and the side bar panel filters. please let me know what i am doing wrong here. I also want to know how do i share this webapp as an url to my co workers.


    • Christoph Glur Post author

      Hi Vish, thanks for reaching out…and sorry for the late response. I’m currently skiing…
      Anyway, I’m afraid I won’t have time to look into this in the next few days. But maybe someone from the community can help? Thx!

      • Vishwanath Math

        Hi Christoph,

        No problem, I will wait for someone to respond, i am excited to launch this webapp in my team so i am making sure that everything works fine,
        Enjoy your Skiing!!


  • Alan

    Amazing tutorial, but I have a question. How can I configure the firewall so that the Shiny app is only accessible on my company’s intranet? I was only able to create public apps following when following this.