Skip to content

R server for knime

Jan Eglinger edited this page Dec 5, 2018 · 34 revisions

The R-server allows to other software to execute R-code, for example to produce plots. In particular there is KNIME that makes extensive use of R-plots.
There are two options:

  1. install R-server on local computer (local R-server)
  2. install R-server on another computer in the network (remote R-server)

Table of Contents

How to setup a local R-Server

  • download R and install it on your computer
  • IMPORTANT: up to R version 3.4 you can follow these steps
    • start R and install the Rserve package
      • copy & paste this line in to R and execute
      • this will install the required package. You need to execute this just once.
  • IMPORTANT: since R version 3.5 you have to follow these steps
  • start the R-server
    • copy & paste this line in to R and execute
    • this will make R to listen for requests from Knime. You need to do this is if no Rserve process is running (e.g. after restart of the computer).
library(Rserve); Rserve(args='--vanilla');
  • check if Rserve process is running via Activity Monitor (MAC) or Task Manager (Windows)
    • make sure only one process is running
    • if Rserve hangs, kill the process and start Rserve again

How to setup a remote R-Server?

  • install R on a computer accessable in your network
  • start R and install the Rserve package (see above)

Setting up the remote R-Server in Mac OSX

To allow remote connections, you need to create a configuration file (if it does not exist) Create a file in /etc/Rserv.conf containing the following lines using a text editor:

 remote enable
 auth disable
 fileio enable
 maxinbuf 500000

If you want the server to be started automatically when the remote computer starts, just create a r-script (e.g. launch_R-server.R) containing:


Then you need a small shell-script to execute the r-script (e.g. Also make sure that the default Application for the sh-extension is the Terminal):

 R CMD BATCH [path to your r-script]

Finally we tell the OS to execute the script at startup (see the box on the right hand side).

You can check if the Rserver is running by starting the "Activity Monitor" verifying if there is a process called Rserve.

Setting up the remote R-Server in Windows

Generally it is not recommended to setup an R-server under Windows (see here, section Installation->Windows)! It also looks like setting up the configuration file is tricky. However...

  • start the R-server by copy & pasting this line into R and execute
library(Rserve); Rserve(args = "--vanilla --RS-enable-remote");
  • check if Rserve process is running via Task Manager (Windows)

Setting up the remote R-Server in Linux (CentOS)

The R frame work can be installed according to the instructions on stackoverflow:

 rpm -Uvh
 yum install R

Like in the previous paragraph a small R-script to launch the server is quite useful. So we create the script /root/Run_Rserve.R containing the following lines:


Then we need to allow remote connections by creating (if it does not exist) /etc/Rserv.conf with the following content:

 remote enable
 auth disable
 fileio enable
 maxinbuf 500000

To control the server via the service utility, which becomes handy if you need to restart the server manually, we create the script /etc/init.d/reserve:

 case "$1" in 
 	cd /root/R
 	R CMD BATCH /root/R/Run_Rserve.R
	pid=`ps -e | grep Rserve | awk '{print $1}'`
	echo "killing Rserve pid=$pid"
	kill "$pid"
	echo $"Usage: $0 {start|stop}"
	exit 2
 exit 0
This allows us to control the server with the command
 service rserve [start|stop]

Then you might want to check if the server is running or not:

 ps -e | grep Rserve

Finally there is a straight forward way to have Rserve started during the boot sequence of the machine is to modify /etc.rc.d/rc.local and add the line

 service rserve start

How to set up connection to KNIME

Go to KNIME > Preferences > KNIME > R-Scripting to tell KNIME who to talk to.

 host: localhost (or IP or DNS of computer running the remote R-server)
 port: 6311
  • to check the connection drag and drop a R Snippet node and connect to some data
  • just execute (no configuration needed) and if successful the R-server connection is working

Install packages required for R templates in Knime

To prepare your R-server for all the tds-templates, you need to install additional packages. For sure scripts can install missing packages also directly from your R-scripts.
These are the links to the templates and might need to be entered into the KNIME preferences:

To install all required packages, run the following lines once in R.

You can’t perform that action at this time.