Arduino and laptop communicate through Python Socket

Hi, I was trying to get my Arduino to connect to my laptop through python socket but so far no success yet.

Here's my Arduino code:

#include <SPI.h>
#include <WiFiNINA.h>

char ssid[] = "iPhone";
char pass[] = "00000000";

int status = WL_IDLE_STATUS;

IPAddress server(129,127,237,229);

WiFiClient client;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  status = WiFi.begin(ssid, pass);
  if (status != WL_CONNECTED) {
    while (true) {
    Serial.println(" No Wifi !");
    delay(1000);
    }
  } else  {
    Serial.println(" YES WIFI!!! ");
    Serial.println("Now connecting to laptop.");
    if (client.connect(server, 1234))  {
      while (1) {
        Serial.println("I'm innnnnnnnnnn!");
        delay(1000);
      }
    }
  }
}

void loop() {
  // put your main code here, to run repeatedly:

}

Here's my Python code:

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

s.bind((socket.gethostname(), 1234)) # bind(ip, port)
print("Done binding.")
s.listen(5)

while True:
	clientsocket, address = s.accept()
	print(f"Connection from {address} has been established!")

I got the Arduino to connect to my iPhone WiFi but not to my laptop through socket.

The IP address I use in the Arduino code (129,127,237,229) is the one I use google to find (googled what's my IP address and Google said it's that number). Am I missing something critical here?

Thanks!

The IP address I use in the Arduino code (129,127,237,229) is the one I use google to find (googled what's my IP address and Google said it's that number). Am I missing something critical here?

Preface: I am not a network specialist.

If you are getting your IP address from an Internet server (ex: whatsmyip.com), it will be the address of your WAN IP. This is how the outside world finds your local network. This WAN IP is usually not your computer. It is usually at least a household router. If you are on a bigger network like a school there might be more complexities in the network.

You would need to port forward your ports to your local IP address if you are using your WAN IP.

You only need to set this up if you are planning to connect to your laptop from outside your local network. For example, you want to go to the coffee shop in town and connect your Arduino to your laptop (still sitting in your room where you left it). In any event, for development purposes, I would not attempt this until I have the device connected on my local network.

Again, I'm not a network specialist, I just know you can't throw around WAN IP addresses trying to connect to servers without having any control over the network and the first steps I take when developing are using servers on my local network (which you have, your laptop) or I hit servers on ports I know are setup for me to do so.