Error passing code to esp32

Traceback (most recent call last):
  File "/home/diego/.platformio/penv/lib/python3.8/site-packages/serial/", line 322, in open
    self.fd =, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
PermissionError: [Errno 13] Permission denied: '/dev/ttyUSB0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/diego/.platformio/packages/tool-esptoolpy/", line 4582, in <module>
  File "/home/diego/.platformio/packages/tool-esptoolpy/", line 4575, in _main
  File "/home/diego/.platformio/packages/tool-esptoolpy/", line 4074, in main
    esp = esp or get_default_connected_device(ser_list, port=args.port, connect_attempts=args.connect_attempts,
  File "/home/diego/.platformio/packages/tool-esptoolpy/", line 120, in get_default_connected_device
    _esp = chip_class(each_port, initial_baud, trace)
  File "/home/diego/.platformio/packages/tool-esptoolpy/", line 313, in __init__
    self._port = serial.serial_for_url(port)
  File "/home/diego/.platformio/penv/lib/python3.8/site-packages/serial/", line 90, in serial_for_url
  File "/home/diego/.platformio/penv/lib/python3.8/site-packages/serial/", line 325, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 13] could not open port /dev/ttyUSB0: [Errno 13] Permission denied: '/dev/ttyUSB0'

Can someone is helping me to solve this problem?

Is another program using your upload port? Like e.g. a serial monitor?

It could also be a problem with not-installed udev rules: Redirecting...