Arduino Yun not connect to server


I have a problem with my arduino yun, try to connect to a server and write values ??in a database, and I have done this with the ethernet shield and it works fine, but when I adapt the code to make it work with the arduino Yun connects only the first time and when I reconnect my arduino yun to the power supply (5V, 1A) does not connect to the server.
Thanks, bye.


#include <Bridge.h>
#include <YunClient.h>

YunClient client;

IPAddress server(0,0,0,0); 
long interval = 60000; // Wait between dumps
double time;
int led = 13;

void setup() {
  // Bridge takes about two seconds to start up
  // it can be helpful to use the on-board LED
  // as an indicator for when it has initialized
  pinMode(13, OUTPUT);


  while (!Serial); // wait for a serial connection

void loop() 
  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.print("time: ");
    // Make a HTTP request:
    client.print( "GET /arduino.php?");
    client.print( "Mega_2560" );
    client.println( " HTTP/1.1");
    client.print( "Host: " );
    client.println( "Connection: close" );
  else {
    // you didn't get a connection to the server:
    Serial.println("Connection failed");

while (!Serial); // wait for a serial connection

Your sketch demands that you open serial monitor before it can start. Remove that line and re-upload

Thanks Federico

I removed that line and arduino yun connects to server even when I reconnect the power supply. Thank you very much. ;)