Cannot syncdb on Heroku
Getting the error when trying to syncdb on Heroku: OperationalError: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"
Answers
There's a good chance you've committed your settings/local.py file to the repo. You need to take it out of git and then deploy to Heroku again.
To remove it git rm --cached microblog/settings/local.py, then add microblog/settings/local.py to your .gitignore file (assuming you're using default paths). Commit that change and push to Heroku. You should be able to syncdb now, assuming you have dj-database-url as @bkonkle mentions.
This error message indicates that Django is trying to use a local Unix socket (which is handled as a small file saved to the filesystem) to connect to the database. With Heroku, this isn't what you want.
Kenneth mentions dj-database-url in the lesson, and I think this is the best way to get Heroku's database connection details into Django's settings. To use it, add it to your requirements.txt and add the following lines to the settings file you're using with Heroku:
# Parse database configuration from $DATABASE_URL
import dj_database_url
DATABASES['default'] = dj_database_url.config()
This will take the DATABASE_URL environment variable and configure the database with it. This environment variable is set automatically by Heroku when you have an active Postgres database addon.