i am getting an error connecting to sql cloud during deployment to google cloud, in my sql cloud, IP public is 34.66.xx.xxx enter image description here but when I run code ./cloud-sql-proxy <connection_name> then feedback:

2024/03/05 22:53:02 Authorizing with Application Default Credentials
2024/03/05 22:53:03 [django-ecommerce-416314:us-central1:django-ecommerce-instance] Listening on 127.0.0.1:5432
2024/03/05 22:53:03 The proxy has started successfully and is ready for new connections!

in my setting code django setting, I config database

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'shopeedb',
        'USER': 'admin',
        'PASSWORD': 'admin',
        'HOST': '34.66.xx.xxx',
        'PORT': '5432',
    }
}

more detail: I can run server on UI server but when LOGIN, REGISTER,... related with DB it not active. What need I do now? Thanks!

I tried change config

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'shopeedb',
        'USER': 'admin',
        'PASSWORD': 'admin',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

results returned: enter image description here but when I run with config

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'shopeedb',
        'USER': 'admin',
        'PASSWORD': 'admin',
        'HOST': '34.66.xx.xxx',
        'PORT': '5432',
    }
}

results returned: 502 bad gate way Nginx

0

There are 0 best solutions below