googlesheets4 localhost refused to connect

the code:


data <- read_sheet("<insert URL to sheet here")

# Define server logic required to draw a histogram
server <- function(input, output) {

# Run the application 
shinyApp(ui = ui, server = server)

when I run this code it redirects to ask for which googl account i want to allow tidyverse API packages with.
after selecting the account it asks me to allow the account permission.
then, confirm my choices, and click 'allow'.

the app cycles and then errors out with:

this site can't be reached - localhost refused to connect

I'm using r studio server community edition on ubuntu 18.04 - there is no gui on this server...administration is done through command line. thus, i do not have my google drive connected to this server. I'm not sure if that's part of the issue or not. i would assume not. if i place this application on i would not have my google drive connected on their infrastructure.

when i putty to the server and run a 'curl' of the URL to the sheet i get basic head information in return, so i know i have a connection between the server and google - it's in the app, but i cannot for the life of me find a guide that solves this.

cheers ~!

Hi @osrs,
when the app opens the browser and asks for permission it redirects to localhost:1410, which corresponds to the R process that waits for the token using port.
But here since you're running the code on the remote server, the R process on the server is waiting to read the response using that port and it gets nothing, because the response is sent to your local computer (localhost:1410) which doesn't have any service listening on that port.
work around:
When you give the app the required permissions and get the error in your browser that the connection to localhost is refused, you will have in the browser the url that contains the token. you copy that url, login using putty and run a curl of that url without changing anything. the R process on the server will get the response.
How it should be solved?
you can take a look at:


I think those listening ports are blocked at the firewall.
Are there any other ports that I should allow that you can think of?

Cheers ~!

This topic was automatically closed 54 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.