I am trying to use python manage.py runserver to show my web page and render it. Django for Professionals says to use Docker. I run the python manage.py runserver command and get this error message.
Error Message
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 136, in inner_run
self.check_migrations()
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/core/management/base.py", line 574, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/db/migrations/loader.py", line 58, in __init__
self.build_graph()
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/db/migrations/loader.py", line 235, in build_graph
self.applied_migrations = recorder.applied_migrations()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/db/migrations/recorder.py", line 89, in applied_migrations
if self.has_table():
^^^^^^^^^^^^^^^^
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/db/migrations/recorder.py", line 63, in has_table
with self.connection.cursor() as cursor:
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/db/backends/base/base.py", line 316, in cursor
return self._cursor()
^^^^^^^^^^^^^^
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/db/backends/base/base.py", line 292, in _cursor
self.ensure_connection()
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/db/backends/base/base.py", line 274, in ensure_connection
with self.wrap_database_errors:
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/db/backends/base/base.py", line 275, in ensure_connection
self.connect()
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/db/backends/base/base.py", line 256, in connect
self.connection = self.get_new_connection(conn_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/django/db/backends/postgresql/base.py", line 275, in get_new_connection
connection = self.Database.connect(**conn_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrewstribling/dev/code/ch4-bookstore/project_env/lib/python3.11/site-packages/psycopg/connection.py", line 750, in connect
raise last_ex.with_traceback(None)
django.db.utils.OperationalError: connection is bad: nodename nor servname provided, or not known
I run these Docker commands and python manage.py runserver
“$ docker-compose down
$ docker-compose up -d”
What have I tried and what am I expecting?
I checked stackoverflow and they said to turn on postgress which I did but there is no change in the error.
I have run a search in django forum for the error message but have not found anything.
I checked the django docs and it just says that this error is treated in a very standard way.
Django Docs Link: Django Exceptions | Django documentation | Django
Can someone explain where I can change the nodename or serv name?