[301] DHCP Failed!

whenever I try to upload the blynkblink code and i check the serial port it states [301] DHCP Failed!
I am running this on the regular blynk servers and dont have much of an idea on how to fix this. could anyone help.

Can you at least explain how your hardware is setup?

1 Like

I’m using an arduino UNO with an ethernet shield. And a RGB led.

@possiblyanidiot I’m guessing you have entered incorrect details for the gateway etc in your sketch or you have faulty hardware. it is more likely to be the former.

Please provide your sketch and ensure it is formatted with the </> button.

Try connecting the ethernet shield from a switch (not directly from the router) . I heaved the same problem before with some kind of routers.

@costas I cant get the code to show here is the haste bin

@Julian78 not sure if there is a restriction on what new Community members can do. So I have added your sketch below. I’ll take a look for any obvious problems.

 Blynk lets you create beautiful drag-and-drop visual interfaces
 for your projects in 5 minutes. And it works with almost every
 hardware out there.

 Docs, Tutorials, everything:  http://www.blynk.cc
 Github:                       http://github.com/blynkkk
 Blynk Community:              http://community.blynk.cc
 Follow Us:                    http://www.facebook.com/blynkapp

 Blynk library is licensed under MIT license
 This example code is in public domain.


 You’ll need, in general:
  - Blynk App (download from AppStore or Google Play)
  - Arduino UNO or similar microcontroller board
  - Decide how to connect Arduino to the Internet (USB, Ethernet,
    Wi-Fi, etc.). Bluetooth is on the way.

 There is a bunch of great example sketches included to show you how to get
 started. Think of them as LEGO bricks  and combine them as you wish.
 For example, take the Ethernet Shield sketch and combine it with the
 Servo example, or choose a USB sketch and add a code from SendData


 Let’s turn ON your LED with Blynk!
 In this example we'll use Arduino UNO + Ethernet Shield

 5 Steps guide:
 (watch video tutorial here: )

  1. Connect LED to Pin 9
  ( http://arduino.cc/en/uploads/Tutorial/simplefade_bb.png )

 In the Blynk App:
  2. Create New Project
  3. Email yourself Auth Token. You can do it later at any time
  4. Add a Button Widget. Select Pin D9 in Widget's Settings
  5. Press Play icon. Enjoy Blynking!


#define BLYNK_PRINT Serial // Enables Serial Monitor
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h> // This part is for Ethernet stuff

char auth[] = "YourAuthToken"; // Put your Auth Token here. (see Step 3 above)

void setup()
  Serial.begin(9600); // See the connection status in Serial Monitor
  Blynk.begin(auth);  // Here your Arduino connects to the Blynk Cloud.

void loop()
  Blynk.run(); // All the Blynk Magic happens here...

  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!

@possiblyanidiot which ethernet shield are you using?

Try the sketch below and ensure you enter your Blynk token and set the correct IP addresses. You need to install the extra Ethernet library as indicated (link provided in the sketch). Let us know if this works:

 * ENC28J60BlynkTest.ino by Costas   Arduino Ethernet
 * This example shows how to use ENC28J60 (UIPEthernet library)
 * to connect your project to Blynk.
 * For this example you need UIPEthernet library:
 *   https://github.com/ntruchsess/arduino_uip
 * Typical wiring would be:
 *  VCC -- 5V
 *  GND -- GND
 *  CS  -- D10  D53 Mega
 *  SI  -- D11  D51 Mega
 *  SCK -- D13  D52 Mega
 *  SO  -- D12  D50 Mega
 *  INT -- D2
 * Button in switch mode connected to D13 (on board LED), Green LED V3, Red LED V4
 * Seconds of up time displayed on V0 and ON / OFF on V1

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <UIPEthernet.h>
#include <BlynkSimpleUIPEthernet.h>
#include <SimpleTimer.h> // here is the SimpleTimer library

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "token goes here"; // Mega Ethernet
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };    //DE:ED:BA:FE:FE:ED
IPAddress arduino_ip ( 192,   168,   10,  120);
IPAddress dns_ip     (  192,   168,   10,   90);
IPAddress gateway_ip ( 192,   168,   10,   90);
IPAddress subnet_mask(255, 255, 255,   0);

bool buttonstatus = true;

SimpleTimer timer; // Create a Timer object called "timer"! 

void setup()

  Blynk.begin(auth, "blynk-cloud.com", 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
  // check if connected here
  int mytimeout = millis() / 1000;
  bool didweconnect = true;  // assume we connected ok
  while (Blynk.connect(13333) == false) {  // try for 40s to connect, standard is 10s with Blynk.connect()
    // Wait until connected
    if((millis() / 1000) >= mytimeout + 39){ // try for less than 39 seconds, then continue with sketch
      didweconnect = false; // failed to connect 
  if(didweconnect == false){
    Serial.println("Failed to connect, check Ethernet connections.");   
    Serial.println("Connected OK");  
  timer.setInterval(1000L, sendUptime); // send up time in seconds, update display widgets and LED's
  digitalWrite(13, HIGH);  // turn on onboard LED at start up

void sendUptime()
  Blynk.virtualWrite(V0, millis() / 1000);
  int ledstatus = digitalRead(13);
  if(ledstatus == 1){
    //Serial.println("Onboard LED is now ON ");
    Blynk.virtualWrite(V1, "ON ");
    Blynk.virtualWrite(V4, 0);
    Blynk.virtualWrite(V3, 255);  
    //Serial.println("Onboard LED is now OFF");
    Blynk.virtualWrite(V1, "        OFF");
    Blynk.virtualWrite(V4, 255);
    Blynk.virtualWrite(V3, 0);  

void loop()
  if(Blynk.connected()){  // this ensures it doesn't just loop trying to reconnect

Do you have inserted an SD card? is your Ethernet shield working without Blynk at all?

What Ethernet shield are you using anyway? I use a loose ENC28J60 ethernet port and it works like a charm.