Configure django storages with sftp server , docker local project

I was trying to configure django-storages to use sftp server to upload static and media to the sftp, however when I do collectstatic it shows "timeout" error

here is my django conf.

USE_NNUH = os.environ.get('USE_NNUH') == 'TRUE'
if USE_NNUH:
    STATICFILES_STORAGE = "storages.backends.sftpstorage.SFTPStorage"
    # SFTP Storage settings
    SFTP_STORAGE_HOST = 'cdn.???.org'
    SFTP_STORAGE_ROOT = '/var/www/html/static/'
    SFTP_STORAGE_PARAMS = {
        'username': '',
        'password': '',
        'allow_agent': False,
    }
    STATIC_URL = 'http://cdn.????.org/static/'
else:
    STATIC_URL = os.path.join(PROJ_DIR, 'public/static/')
    DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
    STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'

I have installed paramiko ( latest version) and I have debug the code, it always stick on connect method and return Timeout error.

another note: my local project works by docker, so when I do the command "collectstatic" I use it inside docker container.. so I think the docker is not able to reach the sftp server... and this is my docker conf for the network:

networks:
  default:
    ipam:
      config:
        - subnet: 192.168.181.0/24

any help would be appreciated ? on how to connect my web app to the sftp server.. I'm trying from days with no luck...

Back to Top