R API for Internet Access

Hi I have R code which I converted to API using plumber package .

r <- plumb("code.R")


The code is in a file code.R

and using the lines above I can access the API from my local machine with the URL http: // localhost: 8000 / functionname

However, when I replace localhost with my IP address and access it from other computers on the network, I cannot access the API. Why is this?


source to share

2 answers

to make the kernel work on my machine.

r$run(host = "",port=8000)


and then to access it just





By default, plumber listens on host, which means it should listen on all devices, be it your IP or localhost. It looks like your computer has a firewall, or your organization might have a firewall in front of the machine in use. You also need to confirm that the IP is being routed (for example, you are not trying to access 192.168 .. from another local network).

I would dissuade you from trying to host the API on your personal machine or on the server where you are doing iterative development, as this requires opening a firewall and accepting traffic on a more sensitive server. The best practice here would be to deploy your API to a server that is dedicated to receiving public traffic. Here's one easy way to get this setup now built into the plumber's development version: https://plumber.trestletech.com/docs/digitalocean/



All Articles