Postgresql and django - Unix domain socket
django, postgresql
Solution
You need to locate a postgres socket. Check main postgres process pid (`ps auxw | grep postgres`) and list its open unix sockets (`lsof -p [PID_OF_POSTGRES_PROCESS] | grep unix`). Write this path to `HOST` option in `settings.py`.
Installing Postgres from distribution package (`apt-get install postgresql`) would be much easier (for example empty HOST in `settings.py` would work) and safer as your distribution will install security updates for you.
Problem
i spend couple of hours to solve these problem but did not reach anything. There are several topics about this problem on the net but none of them says an absolute thing to solve this. I just installed postgresql in order to use it on my django project. ``` DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql_psycopg2", # Add "postgresql_psycopg2", "postgresql", "mysql", "sqlite3" or "oracle". "NAME": "name", # Or path to database file if using sqlite3. "USER": "postgres", # Not used with sqlite3. "PASSWORD": "pass", # Not used with sqlite3. "HOST": "", # Set to empty string for localhost. Not used with sqlite3. "PORT": "", # Set to empty string for default. Not used with sqlite3. } } ``` this is my settings.py and the error is that ``` 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"? ``` Did anyone have a solution about it ?