Can't open "/dev/cu.usbmodem142101" error

I'm running an Arduino Uno R3 on a MacBook Pro 2019 with Mac OSX Big Sur 11.4

My project is to get a IR thermal sensor (model MLX90614) running. There are lots of videos on how to do this and just ran the Adafruit example. I get this error:

An error occurred while uploading the sketch
avrdude: ser_open(): can't open device "/dev/cu.usbmodem142101": No such file or directory

I opened a terminal window and found that there isn't such a file but there is a similar named one: /dev/cu.usbmodem144101

So, do I just edit one of the included files to change this? I see "Wire.h" included but can't find it.

Post the exact error message (s) you're seeing. In code tags

#include <Adafruit_MLX90614.h>

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup() {

Serial.println("Adafruit MLX90614 test");

if (!mlx.begin()) {
Serial.println("Error connecting to MLX sensor. Check wiring.");
while (1);

void loop() {
Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC());
Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF());
Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");


The code compiles but won't upload. These are the exact error messages:

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean,
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "/Applications/"
     User configuration file is "/Users/martinfoster/.avrduderc"
     User configuration file does not exist or is not a regular file, skipping

     Using Port                    : /dev/cu.usbmodem142101
     Using Programmer              : arduino
     Overriding Baud Rate          : 115200

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

avrdude done. Thank you.

Problem uploading to board. See for suggestions.

1 Like

I figured it out. I just needed to edit the preferences.txt to change the /dev/cu.usbmoden142101 to the same but with 144101 (make sure you edit the file with Arduino not running.

This is something that you can change in the tools/port menu of the IDE.
(and it will only show you the ports that are actually there.)

The exact port name on Mac seems to change depending on exactly which usb socket the arduino is plugged in to, and possibly other factors. (I just had a similar situation where all of the port names changed when I rebooted by Mac. Since I was working on some software that created three separate ports on one device, this was especially annoying.)

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.