Sketch hangs on "Ethernet.begin(mac)" statement

I have the following test sketch that hangs on the Ethernet.begin(mac) statement. I implemented the patch described at, but it did not fix the problem.

I’ve connected my PC to the Ethernet cable, so know that everything upstream from the cable is good. The cable goes to a switch, then a router, then a modem, then my ISP.

I would try to debug the Ethernet library code, but can’t figure out how to do Serial.print from within a library.

Help would be much appreciated.

// BEFORE USING, in the code below, 
//      replace "your mac address here" with your device's mac address, and 
//      replace "www, xxx, y, zz" with a valid IP address for your device
#include <SPI.h>
#include <Ethernet.h>

// assign a MAC address for the ethernet controller.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
// fill in your address here:
byte mac[] = { 
//  "your mac address here"};
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00};   // unused MAC address assigned to controller

// fill in an available IP address on your network here,
// for manual configuration:
// my wifi router DHCP address pool is wwww.yyy.x.2 to wwww.yyy.x.254, so the following ip should be ok
//IPAddress ip(www, xxx, y, zz);   //   www, xxx, y, and zz must be replace by valid portions of an IP address
IPAddress ip(192, 168, 1, 1);
// initialize the library instance:
EthernetClient client;

void setup() {
 // Open serial communications and wait for port to open:
  delay(3000);   // delay so user can open serial monitor window

 // start the Ethernet connection:
  Serial.print("start EN: ");
  int w = Ethernet.begin(mac);
  Serial.print("done with BEGIN");
  if (w == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // DHCP failed, so use a fixed IP address:
    Ethernet.begin(mac, ip);
  else {
    Serial.println("confgd via DHCP");

void loop() {

Most common cause of the dhcp fail is having a SD card in the shield’s slot. If you have one there, remove it for a test.

Otherwise, compile and upload this code. It tests the SPI connection between the Arduino and the w5100. If the serial monitor shows, then that part is ok, If it shows anything else, like, then you have a problem there. Insure all pins are inserted fully into the sockets, especially the ICSP pins.

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

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,2,2);

void setup() {

  // disable SD SPI

  // Start ethernet
  Serial.println(F("Starting ethernet..."));
  Ethernet.begin(mac, ip);


void loop() {

Thanks for the suggestion SurferTIm. Tried it and got the ip. Does this mean I have a bad Ethernet shield, or are there other tests I can run to assess the health of the EN mod?

Either a bad shield or a bad pin connection. Check the w5100 IC for solder bridges between pins. Here is a pic posted by another user that shows the problems some ethernet shields have. Here is the post the link is from. More pic links there:

Thanks SurferTim, your test in "Most common cause of the dhcp fail..." helped me out - I simply needed to press the Ethernet shield harder into the Arduino. I was surprised because I thought it was in pretty hard already. Cheers.