Here’s a couple of quick tips to get around the Arduino IDE error message “Serial Port in Use.”  These mostly apply to OSX, but since it is UNIX based, they may make sense for Linux as well.

List Open Files

Applies to:  OSX, Linux.

The check to see if another process (like a previous run of avrdude) is holding the serial port open is easy on both Linux and OSX.  Just open a terminal and run the command: lsof.  The command will report back all files that are currently open by the operating system.  UNIX-based operating systems do everything through files, so this command is useful to see what is keeping a serial device open.  Since lsof gives a list of everything that’s open, and there are a lot of “files”,  use grep to only list what is relevant.

Take a look at your Arduino IDE to see the device name assigned to your Arduino’s virtual serial port.  This name will change based on what USB to Serial chip and operating system you are using.  While you can use the full name like “/dev/tty.usbmodem023432” to search for the open device, I suggest just using a substring like “usbmodem“.

The format of the command is:

[bash firstline=”0”]lsof | grep <device substring>[/bash]

If nothing is returned, then that says no other processes are holding the file (or device handler) open.  If one (or more) processes are returned, you can do some further investigation.

James-MBP2b:~ james$ lsof | grep usbmodem
screen   68202 james   5u   CHR   33,16   0t3418   783 /dev/tty.usbmodem24131
James-MBP2b:~ james$

Here we can see that the process “screen” currently has the serial port open.  (Which I would expect, because I use screen in place of the Arduino Serial Monitor.)  Which, by the way, looks like this on OS X:

JavaAppli 6570 james   48u  CHR  33,16    0t562    783 /dev/tty.usbmodem24131

If you know the process shouldn’t have a hold on the device anymore, you can always make use of the kill command.


Applies to:  OSX.  (Maybe Linux)

If your installation of OSX is missing a writable lock file, you will get a Serial Port in Use error from avrdude, even though it isn’t.  So if you run the lsof command from above and don’t see anything holding the port hostage, then do this quick check to see if the lock file is writable (or exists):

[bash firstline=”0″]ls -l /var/lock[/bash]

If no file exists then run these two commands:

[bash]sudo mkdir /var/lock
sudo chmod 777 /var/lock[/bash]

You’ll be asked for your system password the first time (and then it is remembered for the second) because of the sudo command.  You need temporary admin (root) privileges.  The mkdir comamnd creates a directory or folder while the chmod command will set permissions.  Feel free to click on the each of those links to verify what those commands do.

To be honest, I’m not entirely sure why this works.  Personally, I do not have a lock folder and avrdude connects to my Arduino boards just fine.  However, this simple fix has helped several people in the forums.  Since it is pretty innacious, it might be worth an attempt!

What if it is Still Broken?

These two fixes won’t always solve the Serial port issue.  If you still get the “Serial Port in Use” error even though you verified nothing else is using it, then you might want to post in the Arduino Forums for a bit more help.


Fan of making things beep, blink and fly. Created AddOhms. Stream on Twitch. Video Host on element14 Presents and writing for Hackster.IO. Call sign KN6FGY.


  1. Thank you for this. However, none of the above approaches worked for me. I’m on OSX 10.15.x, and no matter what I tried, I couldn’t get the usb serial port to appear as not busy. However:

    Apparently some arduino boards like the esp32 devkit need to use the USB to UART port. Using this along with matching the baud rate in the serial monitor with what is specified in the sketch did the trick. 🙂

  2. David Howson Reply

    Tried bunches of suggestions, none worked. In Terminal, I entered the lsof as …

    davidhowson@davids-air ~ % davidhowson@davids-air ~ % lsof | grep usbmodem
    Serial 83714 davidhowson 3u CHR 18,155 0t29960 3249 /dev/cu.usbmodem141301

    So it gave me the correct USB port ID, but I have no idea what the other stuff means or whether it’s useful. Uno remains locked up with its on-board sketch that uses Serial.print(data); The sketch runs properly. But I can’t upload anything new. Same on more than one Uno.

  3. Thanks,,,, 2 days trying to use my arduino Mega in El Capitan and finally this made it … great stuff guys. keep up the amazing posts

  4. marschallin Reply

    After running the sudo commands, it worked perfectly! Thanks!

  5. Hello

    The following solution may only be applicable to Windows users but they may end up on this site just like I did.

    The problem with the COM port suddenly becoming “already in use” when trying to access an Arduino through it was, in my case, caused by Windows recognising my Arduino as a “Microsoft Serial BallPoint” mouse. I noticed the above driver name flashing up in the bottom right corner as I connected the Arduino (after having connected it many times before without any problems).
    A hint online elsewhere had me checking for devices in Device Manager that may be using the serial ports. The above mouse driver was listed there under “Mice and other pointing devices”. Once disabled the Arduino comms started working again.

    Good luck,

  6. hey James,

    i was able to upload data to my arduino using your var/lock instructions, but the next time i connected the usb modem did not show up in the serial port list. can you please let me knowhow to fix this?

    some addtional information:
    i used arduino uno.
    i have a macbook pro running 10.9.2.

    when i first connected my arduino nothing popped up from the network preferences and i dont see any thing about arduino in the network preferences.

    this also happen:
    MacBookPro-20C9D048D483-2:~ Kerim$ lsof | grep
    -bash: syntax error near unexpected token `newline’
    MacBookPro-20C9D048D483-2:~ Kerim$

    the light on the Arduino is stilll blinking.
    i have restarted and tried find information on forums. i am also new to arduino and coding. this would be a big help.

    thank you,

    • While the Arduino is connected, open the program “System Information”. It is in the Utilities folder or you can get it from Spotlight.

      Click on the USB section. If you don’t see the Arduino listed then the USB to Serial chip is damaged. This often happens if you apply too much voltage to the 5V pin, or if created a short circuit. If you use “ATmega16u2 (or ATmega8u2) DFU” then the USB to Serial chip has lost its firmware.

      You can search for “ATmega8u2 DFU” for instructions on how to reprogram it.

  7. Hans Meijer Reply

    The lsof helped well. I am trying to get my mac (10.8.4) to talk to a cisco router. lsof helped to reconnect. Connection via screen worked (screen /dev/tty.usbserial), but I can not enter text. Any ideas? Many thanks

    • I don’t know what baud the router would be working at. Don’t forget to include that in the screen command. e.g.
      screen /dev/tty.usbserial 9600

  8. Thanks very much. Creating the lock file fixed the up load problem. OS10.8.2 Arduino 1.0.3

    • Glad it worked for you. I wish I could figure out why some people need it and some people don’t.

Write A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.