Connecting to Spark Livy issue

After running the code to connect to spark Livy, i am getting the below error in Rstudio. In the connection tab it says connected and i can see a session in spark master but the below comes after that and nothing works after that.

"status code 504 returned by rstudio server when executing connection_list _of_objects"

Code :

sc <- spark_connect(master = "",method = "livy",version = "3.3.0")