Reputation: 261
I am trying to setup R Shiny Server on my Amazon Linux AWS EC2 instance and am getting the following error:
An error has occurred
The application failed to start.
The application exited during initialization.
I did a sudo shiny-server to see what happens and see the error EADDRINUSE:
$ sudo shiny-server
[2017-01-29 13:21:22.724] [INFO] shiny-server - Shiny Server v1.5.1.834 (Node.js v6.9.1)
[2017-01-29 13:21:22.728] [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf"
[2017-01-29 13:21:22.764] [INFO] shiny-server - Starting listener on 0.0.0.0:80
[2017-01-29 13:21:22.771] [ERROR] shiny-server - HTTP server error (0.0.0.0:80): listen EADDRINUSE 0.0.0.0:80
[2017-01-29 13:21:22.771] [INFO] shiny-server - Shutting down worker processes
I have verified that Shiny, rmarkdown and, Shiny Server and R are properly installed on my instance:
R --version
R version 3.2.2 (2015-08-14) -- "Fire Safety"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
http://www.gnu.org/licenses/.
> library(shiny)
> library(rmarkdown)
>
I have also checked the network connection on my ec2 instance:
$ sudo netstat --tcp -nlpa | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1875/shiny-server
My ec2 instance network security group:
$ aws ec2 describe-security-groups --group-name launch-wizard-7
{
"SecurityGroups": [
{
"IpPermissionsEgress": [
{
"IpProtocol": "-1",
"PrefixListIds": [],
"IpRanges": [
{
"CidrIp": "0.0.0.0/0"
}
],
"UserIdGroupPairs": [],
"Ipv6Ranges": []
}
],
"Description": "launch-wizard-7 created 2017-01-28T14:22:51.817-05:00",
"IpPermissions": [
{
"PrefixListIds": [],
"FromPort": 80,
"IpRanges": [
{
"CidrIp": "0.0.0.0/0"
}
],
"ToPort": 80,
"IpProtocol": "tcp",
"UserIdGroupPairs": [],
"Ipv6Ranges": []
},
(there's another entry but that ssh into my own machine so I won't put that information)
and here is my shiny-server.conf file from /etc/shiny-server/shiny-server.conf
$ cat /etc/shiny-server/shiny-server.conf
# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;
# Define a server that listens on port 3838
server {
listen 3838;
# Define a location at the base URL
location / {
# Host the directory of Shiny Apps stored in this directory
site_dir /srv/shiny-server;
# Log all Shiny output to files in this directory
log_dir /var/log/shiny-server;
# When a user visits the base URL rather than a particular application,
# an index of the applications available in this directory will be shown.
directory_index on;
}
}
Any help would be really appreciated. I tried to let AWS listen to request for port 80 for all ip addresses and for the shiny-server as I thought maybe both services shouldn't be listening to the same port but that didn't work. Am just trying to deploy the sample-app that came with shiny server.
url: http://34.198.107.126/sample-apps/hello/
Upvotes: 4
Views: 7427
Reputation: 52208
I had the same error because the port was already in use (a crashed process could be hogging the port, or a legitimate program could be using it).
A simple solution could be to try on another port. Otherwise try some/all of the following:
To check to see if any process is using the port you're trying to use (change 3838 to the port you're interested in):
netstat -an | grep 3838
tcp46 0 0 *.3838 *.* LISTEN
If you see something there, you know the port is in use (a port that isn't in use won't return any result).
To see what process is using port 3838:
lsof -i tcp:3838
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
com.docke 23298 st 115u IPv6 0xfa130c123d3bd073 0t0 TCP *:sos (LISTEN)
If you're happy to kill the process (use the process ID found above):
kill -9 23298
After this the shiny app worked as expected.
Upvotes: 1
Reputation: 261
nevermind, figured out what it was; everything was setup properly but my r packages were not installed as root but as ec2-user; installing as root worked as the webpages/folders permissions are mostly root.
Upvotes: 2