Sometimes, a local project may fail to start up. You may see:

This page isn’t working didn’t send any data.

in your web browser, or:

django.db.utils.OperationalError: could not connect to server: Connection refused
Is the server running on host "postgres" ( and accepting TCP/IP connections on port 5432?

in the console or logs.

This almost always means that the Django runserver has started up, but wasn't able to connect to the database. Usually, this is because although the web container and the database container were launched at the same time, the database was slower to get started, and when Django tried to connect to it, it found nothing there.

The solution is to restart Django, while leaving the database running.

Try these steps in order:

  1. stop the web server (divio project stop  or docker-compose stop , or stop it in the Divio app)
  2. start the web server in the Divio shell with docker-compose up   (this will allow you to see the console as it runs)
  3. try loading the site in the web browser - you may get the error about the database connection failure; if so, go on to:
  4. find the   file in the project
  5. save it - you don't need to make any changes, the action of saving any Python file in the project will cause the Django runserver to restart
  6. in the shell, you will see that the runserver has restarted
  7. if it shows no errors since the restart, try loading the site in the browser once more.
Did this answer your question?