Forums

django.db.utils.OperationalError: could not translate host name

I did everything according to manual. that's my settings.py:

  • DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'test_spatial', 'USER': 'postgre_user', 'PASSWORD': os.getenv("Password"), 'HOST': 'postgre_user-676.postgres.pythonanywhere-services.com', 'PORT': 12676, } }

from postgresql console: postgres=# CREATE USER postgre_user WITH PASSWORD ''; CREATE ROLE postgres=# ALTER ROLE postgre_user SET client_encoding TO 'utf8'; ALTER ROLE postgres=# ALTER ROLE postgre_user SET default_transaction_isolation TO 'read committed'; ALTER ROLE postgres=# ALTER ROLE postgre_user SET timezone TO 'UTC'; ALTER ROLE postgres=# GRANT ALL PRIVILEGES ON DATABASE test_spatial TO postgre_user ; GRANT And finally i got for python manage.py migrate: django.db.utils.OperationalError: could not translate host name "postgre_user-676.postgres.pythonanywhere-services.com" to address: Name or service not known What did i do wrong?

Where did you get postgre_user-676 from? The correct hostname to use is on the Postgres tab on your Databases page.

I got it from docs from example configuration of django https://help.pythonanywhere.com/pages/PostgresGettingStarted/

  • List item 'HOST': 'myusername-667.postgres.pythonanywhere-services.com', 'PORT': 10667,

lol ok thank you