Can only access server on my router

I have a wifi shield that I am using as a wifi server to control a servo and read a sensor. I checked it on my phone at home and it worked perfectly. Then I decided to check it away from my home and I couldn’t reach the website. If I use wifi i’m fine. If I use cellular it doesn’t work. Any suggestions? sorry for the messy code:

#include <SPI.h>
#include <WiFi.h>
#include <Servo.h>
 
char ssid[] = "Yuna.Wilson";      // your network SSID (name)
char pass[] = "Four1735";   // your network password
int keyIndex = 0;                 // your network key Index number (needed only for WEP)
int status = WL_IDLE_STATUS;
WiFiServer server(80);
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created
int purchase=0; 
int pos = 0;    // variable to store the servo position
const int analogInPin1 = A0;
int sensorValue1 = 0;
String readString = String(30);
String state = String(3);
void setup() {
  myservo.attach(9);  // MAKE SURE 9 IS AN OPEN pIN
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
 
  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while(true);
  }
 
  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:   
    status = WiFi.begin(ssid, pass);
    // wait 10 seconds for connection:
    delay(10000);
  }
  server.begin();
  // you're connected now, so print out the status:
  printWifiStatus();
    //Sets the LEDpin as an output
 
 
 
  state = "CLOSED";
}

void loop() {
  // listen for incoming clients
  WiFiClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (readString.length() < 30) {
          readString.concat(c);
        }
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          int LED = readString.indexOf("LED=");
          if (readString.substring(LED,LED+5) == "LED=T") {
          myservo.attach(9); // turn servo on

       for(pos = 150; pos>=20; pos-=1)  // 20 is open 150 closed
           {                               
             myservo.write(pos);       // tell servo to go to pos
             delay(10);                // waits 10ms to get to pos
           }
           
            state = "OPEN";
          }
          else if (readString.substring(LED,LED+5) == "LED=F") {
            for(pos = 20; pos < 150; pos += 1)  // 20=open 150=closed
    {                                  // in steps of 1 degree
             myservo.write(pos);              // tell servo to go 'pos'
             delay(15);       // waits 15ms for servo to reach position
            }
            myservo.detach();
            state = "CLOSED";
          }
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
           Serial.print("made it past http");
          client.print("LID is ");
          client.print(state);
          client.print("

");
         
          if (state == "OPEN") {
          sensorValue1 = analogRead(analogInPin1);
          if (sensorValue1>100){
             purchase=1;         
             }
            client.println("<a href=\"./?LED=F\">Close Lid<a>");
            client.print("number of purchases ");
            client.print(purchase);
            
          }
          else {
            client.println("<a href=\"./?LED=T\">Open  Lid<a>");
          }
         
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    readString = "";
    // close the connection:
    client.stop();
  }
}
void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());
  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);
  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

Your router probably does NAT (https://en.wikipedia.org/wiki/Network_address_translation). If you want to have access to your Arduino from the Internet, you have to configure your router to forward that traffic to the WiFi shield. How to do that does depend on the router you use, it's manual should provide instructions on that.

I'm sure you are on the right track. I did port forwarding on port 80 for HTTP to the IP address of the Arduino. I updated the firmware on the router as well.

Alas, the same situation. I am fine if I'm on my wifi but when I go cellular it doesn't work.

I even switch to cellular and hit reload with no success.

pylon: Your router probably does NAT (https://en.wikipedia.org/wiki/Network_address_translation). If you want to have access to your Arduino from the Internet, you have to configure your router to forward that traffic to the WiFi shield. How to do that does depend on the router you use, it's manual should provide instructions on that.

I even switch to cellular and hit reload with no success.

Sure, because you cannot access the Arduino with the same IP address. Let's assume it has the IP 192.168.1.34 on your LAN. You can access it with a web browser an the URL

http://192.168.1.34/

But from the internet you need the public IP address (the one your router gets from the Internet supplier), so if your router got 20.30.40.55 (you MUST adapt that!), you have to change the URL to

http://20.30.40.55/

Keep in mind: in most cases (or better with most suppliers) this IP changes more or less frequently. One possible solution for this problem is the use of DynDNS but not all routers support this.