Django flexible app not getting connected with postgres instance

34 views
Skip to first unread message

BrainPlow Administrator

unread,
Aug 2, 2017, 9:50:53 AM8/2/17
to Google App Engine, Amad ud Din
Currently I am trying to deploy a Django app on Google App Engine(GAE). All goes well and app is deployed, but when it gets deployed, its connection with Postgres instance lost. I don't know why this happening. following is my settings.py file.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'dbname',
        'USER': 'username',
        'PASSWORD': 'password',

    }
}
# In the flexible environment, you connect to CloudSQL using a unix socket.
# Locally, you can use the CloudSQL proxy to proxy a localhost connection
# to the instance
DATABASES['default']['HOST'] = '/cloudsql/<instance-name>'
if os.getenv('GAE_INSTANCE'):
    pass
else:
    DATABASES['default']['HOST'] = '100.107.126.241'

When i run it locally, it's making connection with google cloud Postgres as i have given ipv4 address to make connection, but as soon as i deploy it on GAE, following error comes while accessing database.

Is the server running locally and accepting connections on Unix domain socket "/cloudsql/shopnroar-175407:us-central1:snr-instance1/.s.PGSQL.5432"?

here is my app.yaml

# [START runtime]
runtime: python
env: flex
entrypoint: gunicorn -b :$PORT SNR.wsgi

env_variables:
    # Replace user, password, database, and instance connection name with the values obtained
    # when configuring your Cloud SQL instance.
    SQLALCHEMY_DATABASE_URI: >-
      postgresql+psycopg2://user:password@/shopnroar?host=/cloudsql/<connection-name>
beta_settings:
    cloud_sql_instances: shopnroar-175407:us-central1:snr-instance1

runtime_config:
  python_version: 2
# [END runtime]

Can anybody help me in this regard. i am stuck here for previous two days. i was working on heroku before it. i am new here. i love to work with google but this error has stuck me here for two days.



Shivam(Google Cloud Support)

unread,
Aug 2, 2017, 1:42:51 PM8/2/17
to Google App Engine, amad....@brainplow.com

Google Groups is meant for general product discussions only and not for technical support. I suggest to post this on one of the Stack Exchange sites as explained here. Make sure that you select the right tags.



Reply all
Reply to author
Forward
0 new messages