Arduino build error

fatal error: Servo.h: No such file or directory

The compiler looked for the file named in an #include line and it is not there.

  • Build error
  • 3 common causes
  • Seen 673 times in failed builds on Mokxi in the 30 days to November 16, 2026.
The message

What the Arduino IDE prints

Output window
sketch.ino:1:10: fatal error: Servo.h: No such file or directory
    1 | #include <Servo.h>
      |          ^~~~~~~~~
compilation terminated.
exit status 1

Either the name does not match the real header exactly, the library is not installed, or the file is your own and is not in the sketch.

Mokxi's compiler, clang, words it as 'Servo.h' file not found.

Causes

The 3 usual causes with the fix

1The header name is not the library’s header name

A letter too many, a missing underscore or the wrong capitals all give this error. Windows and most Macs ignore capitals in file names and Linux does not, so a sketch can build on one machine and fail on another. Copy the name from the library, or from its example.

Broken
#include <Servos.h>

Servo gate;

void setup() {
  Serial.begin(9600);
  gate.attach(9);
  Serial.println("servo ready");
}

void loop() {
}
Fixed
#include <Servo.h>

Servo gate;

void setup() {
  Serial.begin(9600);
  gate.attach(9);
  Serial.println("servo ready");
}

void loop() {
}

Mokxi’s build tab says: Mokxi has no Servos.h, and ships Servo.h, one or two letters away: if that is the library you mean, write #include <Servo.h>.

Try this fix in Mokxi

2The library is not installed

A library that does not ship with the Arduino IDE has to be installed once before its header exists. Your sketch can be perfect and still fail until then. Mokxi already has the common ones, so a sketch like this builds there as it is.

  1. In the Arduino IDE, open Sketch, Include Library, Manage Libraries.
  2. Search for the library by the name its example uses, here Adafruit NeoPixel, and press Install.
  3. Accept the other libraries it asks for, then compile again.
Works once the library is installed
#include <Adafruit_NeoPixel.h>

Adafruit_NeoPixel strip(8, 6, NEO_GRB + NEO_KHZ800);

void setup() {
  Serial.begin(9600);
  strip.begin();
  strip.show();
  Serial.println("strip ready");
}

void loop() {
}

Try this fix in Mokxi

3A header of your own that is not in the sketch

A line like #include "pins.h" with quotes means a file in your sketch folder. If no tab named pins.h exists, the compiler cannot open it. Add the tab, or put the constants in the sketch itself.

Broken
#include "pins.h"

void setup() {
  Serial.begin(9600);
  pinMode(LED_PIN, OUTPUT);
  Serial.println(LED_PIN);
}

void loop() {
}
Fixed
const int LED_PIN = 8;

void setup() {
  Serial.begin(9600);
  pinMode(LED_PIN, OUTPUT);
  Serial.println(LED_PIN);
}

void loop() {
}

Mokxi’s build tab says: This project has no file named pins.h.

Try this fix in Mokxi

FAQ

Questions and answers

What does 'No such file or directory' mean in an Arduino build?

An #include names a header file the compiler cannot find. The name is spelled differently from the real file, the library is not installed, or your own file is missing from the sketch.

Why does the same sketch build on Windows and fail on Linux?

Windows and most Macs ignore capital letters in file names, and Linux does not. #include <servo.h> finds Servo.h on the first two and fails on Linux.

Do I need to install libraries in Mokxi?

Not the common ones. Servo, Wire, LiquidCrystal_I2C, Adafruit_NeoPixel, DHT and many more are built in. A header Mokxi does not ship is named in the build tab with the closest one it does.