WebClient example with static IP not working

Any ideas? I'm using the WebClient example from the Ethernet library on Arduino 1.0 with no modifications except adding a static IP address. It works fine with DHCP, but with a static IP the client.connect() call fails.

Here is the failure I get in the console - just as if the server doesn't respond.

connection failed


I've even tried increasing the delay to 5s in case the WizNET chip isn't done initializing the registers... I don't believe that's the problem, just trying something.

Here are the only changes I've made to the default sketch:


  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:


  IP Address xyz(192,168,1,122);

That is a free IP on my subnet and there is no conflicts. I can ping the the board once the sketch starts. This is with an official ethernet shield and mega 2560.

Any ideas?

IP Address xyz(192,168,1,122);

I hope that was a typo. IPAddress is one word. This is what I use.

IPAddress ip(192,168,1,122);

void setup()


   // rest of setup code   

Maybe your router ip (gateway for the Arduino) is not Have you checked that on other localnet computers to see if there is a difference?

Yeah it was a typo in the post, sorry. I do have IPAddress.

The default gateway is and the DNS server is the same, subnet mask is I've even created 3 other objects to represent those (even though the (mac,ip) arguments are all that's needed in this case) and passed those into begin() to see if that changes it but I still get the same result - failure.

What brand and model of router are you using? Some are very particular about the ip range you assign for static ips. They will freak out if you assign a static ip that is within the range of the dhcp server ip pool, especially if they have already issued a dynamic ip for that mac address.

I trick my router by changing the mac address a little for each type of ip assignment.

It's not the network. It's definitely something with the Arduino. I can try it at another place to be 100% sure.

Let me note again that I CAN ping the board when I assign a static IP.

Does your router have an http login/setup page on
If so, see if the Arduino will connect there.

edit: Have you checked what ip the ethernet shield gets when you use dhcp?