Using a switch to connect the Arduino

I’m using a Gigabit switch and plugging in my PC, the Arduino and my internet cable into three ports on it. But for some reason, the client.connect function does not seem to be working. I presume this may be because I am using a switch and not connecting it directly. Any ideas?

/*

*/

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0x90, 0xA2, 0xDA, 0x10, 0xCB, 0x78};
IPAddress ip(192, 168, 1, 177);
IPAddress server(64, 233, 187, 99 );

EthernetClient client;

void setup() {
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println("connecting...");
   while(!client){
    ; // wait until there is a client connected to proceed
  
  Serial.println("not working");
   }
  if (client.connect(server, 80)) {
    Serial.println("connected");
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}


void loop() {
    
}

This just prints “connecting…” once and then “not working” indefinitely. I think that since it is printing connecting, it is at least able to initialize.

Installation & Troubleshooting

"For problems with Arduino itself, NOT your project"

There are some problems know with some types of gigabit switches which cannot negotiate the speed correctly and disables the port. What speed does your switch show on the port the Arduino is connected? What type of switch are you using? Is your router on the IP 192.168.1.1?

Problem solved! Turns out I was looking for the client before I used client.connect and started the connection. Thanks!