Django deploy on App Engine raise error: connection to server at "127.0.0.1", port 5432 failed:
Я пытаюсь развернуть свое веб-приложение django на Google Cloud App Engine, но сталкиваюсь с ошибкой подключения. Это происходит после того, как я выполнил все настройки, такие как main.py, точка входа, app.yaml.
После проведения некоторых исследований, все они указывают на то, что моя база данных postgresql каким-то образом блокирует мои соединения, но я проверил и моя база данных работает на sql cloud.
Вот скриншот ошибки:
<Вот мой app.yaml файл:
# [START django_app]
runtime: python38
handlers:
# This configures Google App Engine to serve the files in the app's static
# directory.
- url: /static
static_dir: static/
# This handler routes all requests not caught above to your main app. It is
# required when static routes are defined, but can be omitted (along with
# the entire handlers section) when there are no static files defined.
- url: /.*
script: django_blog.wsgi.application
env_variables:
APPENGINE_URL: https://engineblog.wn.r.appspot.com
#entrypoint: gunicorn -b :$PORT django_project.wsgi:main
inbound_services:
- warmup
# Only pure Python libraries can be vendored
# Python libraries that use C extensions can
# only be included if they are part of the App Engine SDK
# Using Third Party Libraries: https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27
# libraries:
# - name: MySQLdb
# version: 1.2.5
# [END django_app].
Вот мой home.html который является файлом, который django показывает для ошибки
{% extends "base.html" %}
{% block content %}
{% for post in post_list %}
<div class="post-entry">
<h2>
<a href="">{{ post.title }}</a>
<p>{{ post.body }}</p>
</h2>
</div>
{% endfor %}
{% endblock content %}
и мой setting.py файл:
Я нахожусь в затруднительном положении, поэтому буду признателен за помощь. [1]: https://i.stack.imgur.com/bDIfY.png
Согласно этой документации, чтобы проверить, работаете ли вы в Production или нет, вы должны сделать
следующееif os.getenv('GAE_ENV', '').startswith('standard'):
# Production in the standard environment
else:
# Local execution.
Если вы выведете дикт для os.getenv, вы увидите значение gunicorn/20.1.0.
для "SERVER_SOFTWARE"