avrdude: ser_open(): can't open device

Hello,
I am trying to flash the default ‘sweep’ program on my Arduino Mega 2560 (IDE 1.0.5). Arduino gives me the error :

avrdude: ser_open(): can't open device "/dev/ttyACM0": No such file or directory

This error occurs, if and only if I connect the signal wire of my servo to PWM pins 8,9,10,11,12. If I connect the wire on the rest of the PWM pins, there is no error and the program is loaded successfully.
Now, once the program is loaded successfully, the servo acts weird. It rotates few degrees in the clockwise direction, waits for approx 9 seconds and then rotates the same amount in the anti clockwise direction.
Just yesterday I operated LCD using the pins 11,12 and it gave me no error.
The ‘sweep’ code is as follows :

#include <Servo.h> 
 
Servo myservo; 
 
int pos = 0;    // variable to store the servo position 
 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 
 
 
void loop() 
{ 
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
}

I would like to add that the above thing happens with 5 different new brand servos.

I have come to the realisation that I might need to change the board. Just making sure that’s the case before I buy a new one.

Thanks in advance for any help. Appreciate it.