Unable to open COM port

Hello! Im currently trying to upload code into my arduino pro mini ATMEGA328PB using a ftdi232rl, but no matter what i do it always gives this error:

Sketch uses 1998 bytes (6%) of program storage space. Maximum is 32384 bytes.
Global variables use 270 bytes (13%) of dynamic memory, leaving 1778 bytes for local variables. Maximum is 2048 bytes.
Error: cannot open port \.\COM4: Access is denied.

Error: unable to open port COM4 for programmer urclock
Failed uploading: uploading error: exit status 1

Hi @divyansh_171. There is a known bug in Arduino IDE 2.x that can cause uploads to fail with this "Access is denied" error if you try uploading to a board like the official Nano that uses an FTDI FT232R USB chip while the Arduino IDE Serial Monitor or Serial Plotter is open.

A port can only be used by one process at a time, so Arduino IDE must automatically close the port in Serial Monitor and Serial Plotter during an upload, automatically opening it again after. For some reason, that juggling of the port control is not working with boards that have the FTDI USB chip.

If that bug is the cause of the problem you are having, the workaround will be to manually close the port in Serial Monitor/Serial Plotter before doing an upload. Please give that a try and then let me know if you still have the error while uploading:

Serial Monitor

  1. Click the X icon on the "Serial Monitor" tab in the bottom panel of the Arduino IDE window to close the tab:
  2. Upload the sketch.
  3. Open Serial Monitor again if needed (by clicking the icon on the IDE toolbar or the Tools > Serial Monitor menu item) after the upload is finished.

Serial Plotter

If you have the "Serial Plotter" window open, the procedure is a bit different from closing the Serial Monitor connection:

  1. Close the "Serial Plotter" window.
  2. If the "Serial Monitor" view is not already open, select Tools > Serial Monitor from the Arduino IDE menus to open it.
    ⓘ We must do an open/close cycle on Serial Monitor as a workaround for a bug in Serial Plotter
  3. Click the X icon on the "Serial Monitor" tab in the bottom panel of the Arduino IDE window to close the tab:
  4. Upload the sketch.
  5. Open Serial Monitor and/or Serial Plotter again if needed after the upload is finished.

Please let me know if you have any questions or problems while following those instructions.

Hello @ptillisch ! i tried this method however im still getting an error...my question is that im using a 3rd party wire to connect the ftdi to my PC, and if thats a problem?
i seem to be getting 3 types of error messages while doing essentially the same thing:

type 1:

Warning: attempt 1 of 10: not in sync
Warning: attempt 2 of 10: not in sync
Warning: attempt 3 of 10: not in sync
Warning: attempt 4 of 10: not in sync
Warning: attempt 5 of 10: not in sync
Warning: attempt 6 of 10: not in sync
Warning: attempt 7 of 10: not in sync
Warning: attempt 8 of 10: not in sync
Warning: attempt 9 of 10: not in sync
Warning: attempt 10 of 10: not in sync
Warning: programmer is not responding; try -x strict and/or vary -x delay=100
Error: unable to open port COM4 for programmer urclock
Failed uploading: uploading error: exit status 1

type 2:
Sketch uses 1998 bytes (6%) of program storage space. Maximum is 32384 bytes.
Global variables use 270 bytes (13%) of dynamic memory, leaving 1778 bytes for local variables. Maximum is 2048 bytes.
Error: unable to read: The I/O operation has been aborted because of either a thread exit or an application request.

Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Warning: attempt 1 of 10: not in sync
Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Warning: attempt 2 of 10: not in sync
Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Warning: attempt 3 of 10: not in sync
Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Warning: attempt 4 of 10: not in sync
Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Warning: attempt 5 of 10: not in sync
Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Warning: attempt 6 of 10: not in sync
Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Warning: attempt 7 of 10: not in sync
Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Warning: attempt 8 of 10: not in sync
Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Warning: attempt 9 of 10: not in sync
Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Warning: attempt 10 of 10: not in sync
Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Warning: programmer is not responding; try -x strict and/or vary -x delay=100
Error: unable to write: sorry no info avail
Error: unable to read: Access is denied.

Error: unable to open port COM4 for programmer urclock
Failed uploading: uploading error: exit status 1

type 3:
Sketch uses 1998 bytes (6%) of program storage space. Maximum is 32384 bytes.
Global variables use 270 bytes (13%) of dynamic memory, leaving 1778 bytes for local variables. Maximum is 2048 bytes.
Error: cannot open port \.\COM4: The system cannot find the file specified.

Error: unable to open port COM4 for programmer urclock
Failed uploading: uploading error: exit status 1

I presume you mean a USB cable? That's possible if the "wire" is a charging cable only and not a fully featured (data + charging) USB cable.

I actually dont know, i found the cable in my room and since it was type b mini to type a and was plugging into the serial adapter i assumed it was good to go.

Just realised that the Pro Mini doesn't have a USB connector, so when you are referring to 'a ftdi232rl', then do you mean one of those FTDI modules?

If so, then how have you wired this up to the Pro Mini?
In particular, how have you wired DTR?

A diagram of all the connections would be helpful even if hand drawn.

Also, do you have the 5V or the 3.3V Pro Mini?
Have you set the voltage jumper on the FT232RL module to match?

Have you restarted your computer?

Yeah basically i have female to female jumper wires connecting the pro mini and the FTDI module, and yes the picture you’ve given is the exact module i have. The DTR pin of the FTDI is connected to the DTR pin of the Pro mini, the TX pin of the FTDI is connected to the RXO pin of the Pro mini, the RX pin of the FTDI is connected to the TXI pin of the pro mini, the CTS pin of the FTDI is connected to the GND
pin of the Pro mini, the, the VCC pin of the Pro Mini is connected to the VCC pin of the FTDI and the GND pin of the Pro mini is connected to the GND pin of the FTDI

Yes

I have the 5V pro mini and ive set the plastic cap of the FTDI over the 5V pin

Plug your phone into the USB mini cable end and the USB A into your computer. Do you hear a system chime?

Yeah i hear a system chime and it seems the FTDI and Pro Mini are getting power

That's a good step.

Would you show your Device Manager "LPT & COM"... here's mine...

Im not home currently although i did take a look at this before because google told me so, and there was COM1 which was Communications and COM3 which was the FTDI

Windows will change the COMx port in use. My "COM4" will change almost every time I start the IDE. Check when you start your IDE.

Wait you’re saying that when i open the IDE the COM port for the FTDI changes?

Windows may change COM port numbers. I do not know why. I could be using the same sketch, unplug my Arduino, plug it in again, and the COM port will need to be updated by me in the IDE.

Ah well i don’t seem to have that problem…In your opinion do you think buying a new cable is worth a shot?

Not yet. The problem might not be the cable. Prove it is "power only" or "data and power" through testing.

I get my "new cables" from roadside parking spaces where people drop data cables all the time (crushed ones get discarded). Every workcenter and living space seems to have a large box of "electronics" cables for all the USB data devices, which may be just what you need. Some people might warn you of never picking up cables, due to "rubber ducky" (nefarious electronics in the connectors), but that, statistically, never happens. I have a box of 20 roadside cables and I probably gave away 100 other cables. All tested for short-circuits. All labeled "C"omm or "P"ower (because "D"ata is too close in shape to "P").

As for as i know, from my end apart from teh cable being a bit loose and difficult to get into the ports, its working perfectly fine although i really do not know what more to do especially since im on a deadline right now