Error trying to use Spark in RStudio

I am trying to use Spark in RStudio but when I enter the command

"sc<-spark_connect(master = "local")"

I get the following error message:

"Error in spark_connect_gateway(gatewayAddress, gatewayPort, sessionId, :
Gateway in localhost:8880 did not respond."

How can I resolve this issue and get Spark to run? I have a PC with Windows 11, Java and Spark version 3.0.3 installed.

Hi @scmeyer41 , welcome to Community. This may be an issue with Windows firewall. Java needs access to communicate via several ports, at the very least 8880