Skip to content
Calin Dragomir edited this page Oct 30, 2021 · 5 revisions

Why isn't my project running?

1. The database doesn't exist

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

That's probably because your docker container died along the way or you forgot to turn it back on (I do that all the time). To fix this, you can docker container start postgres-risc; if you get an error, make sure the docker container was created (docker ps -a) and run the steps from the beginning of the Initial set-up.

2. The database password is wrong

django.db.utils.OperationalError: FATAL:  password authentication failed for user "seism"

Make sure you're using the right command from the README and that it matches the DATABASESs' USER and PASSWORD from settings.py.

3. Cannot install psycopg2

If you're on Mac and you see this error while setting up your local virtualenv:

Collecting psycopg2==2.9.1
  Using cached psycopg2-2.9.1.tar.gz (379 kB)
    ERROR: Command errored out with exit status 1:
     command: <PATH_TO_ENV>/seismic-risc/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/5q/_n9lmfrs6wq3l_yf47mqqhx40000gq/T/pip-install-u1ki73eo/psycopg2_237524dcb59440ee9b0ec73e7fc1e5a2/setup.py'"'"'; __file__='"'"'/private/var/folders/5q/_n9lmfrs6wq3l_yf47mqqhx40000gq/T/pip-install-u1ki73eo/psycopg2_237524dcb59440ee9b0ec73e7fc1e5a2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/5q/_n9lmfrs6wq3l_yf47mqqhx40000gq/T/pip-pip-egg-info-0q_ze2q1
         cwd: /private/var/folders/5q/_n9lmfrs6wq3l_yf47mqqhx40000gq/T/pip-install-u1ki73eo/psycopg2_237524dcb59440ee9b0ec73e7fc1e5a2/
    Complete output (23 lines):
    running egg_info
    creating /private/var/folders/5q/_n9lmfrs6wq3l_yf47mqqhx40000gq/T/pip-pip-egg-info-0q_ze2q1/psycopg2.egg-info
    writing /private/var/folders/5q/_n9lmfrs6wq3l_yf47mqqhx40000gq/T/pip-pip-egg-info-0q_ze2q1/psycopg2.egg-info/PKG-INFO
    writing dependency_links to /private/var/folders/5q/_n9lmfrs6wq3l_yf47mqqhx40000gq/T/pip-pip-egg-info-0q_ze2q1/psycopg2.egg-info/dependency_links.txt
    writing top-level names to /private/var/folders/5q/_n9lmfrs6wq3l_yf47mqqhx40000gq/T/pip-pip-egg-info-0q_ze2q1/psycopg2.egg-info/top_level.txt
    writing manifest file '/private/var/folders/5q/_n9lmfrs6wq3l_yf47mqqhx40000gq/T/pip-pip-egg-info-0q_ze2q1/psycopg2.egg-info/SOURCES.txt'

    Error: pg_config executable not found.

    pg_config is required to build psycopg2 from source.  Please add the directory
    containing pg_config to the $PATH or specify the full executable path with the
    option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.

    For further information please check the 'doc/src/install.rst' file (also at
    <https://www.psycopg.org/docs/install.html>).

You'll need to first run brew install postgresql , then you can re-run the pip install psycopg2 command.

Clone this wiki locally