Edit to ask who thought that this question had anything to do with the "possibly related" one.
I have a fairly simple django (1.11) project using the rest_framework that works fine when I start it from the command line, typing
nohup python manage.py runserver 0.0.0.0:4448 &
on centos. Connects to a postgresql database, with
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'my_database',
'USER': 'my_user',
#'PASSWORD': 'mypassword',
'HOST': '127.0.0.1',
' PORT': '5432',
}
}
in my settings.py file. However if I set up the runserver command to run at boot time from a cron I get the following when I send a request to the application:
... lot of stuff
django.db.utils.OperationalError: could not connect to server: Connection
refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
and in my pg_hba file I have
IPv4 local connections:
host all all 127.0.0.1/32
trust # local host
host all all 10.2.11.53/32
trust
host all my_user 0.0.0.0/0 trust
and also I have
netstat -plunt | grep post
tcp 0 0 10.2.11.53:5432 0.0.0.0:* LISTEN
867/postmaster
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
867/postmaster
Any suggestion?
Thanks,
a
PS The full traceback:
Unhandled exception in thread started by <function wrapper at 0x1a11230>
Performing system checks...
[<RegexURLPattern batch-batch-done ^batch/batch-done/$>, <RegexURLPattern batch-load-urls ^batch/load-urls/$>, <RegexURLPattern batch-request-batch ^batch/request-batch/$>, <RegexURLPattern batch-schedule-job ^batch/schedule-job/$>]
System check identified no issues (0 silenced).
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 128, in inner_run
self.check_migrations()
File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 422, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/usr/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "/usr/lib/python2.7/site-packages/django/db/migrations/loader.py", line 52, in __init__
self.build_graph()
File "/usr/lib/python2.7/site-packages/django/db/migrations/loader.py", line 209, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/usr/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "/usr/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 52, in ensure_schema
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
File "/usr/lib/python2.7/site-packages/django/db/backends/base/base.py", line 254, in cursor
return self._cursor()
File "/usr/lib/python2.7/site-packages/django/db/backends/base/base.py", line 229, in _cursor
self.ensure_connection()
File "/usr/lib/python2.7/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/usr/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/lib/python2.7/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/usr/lib/python2.7/site-packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/lib/python2.7/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
connection = Database.connect(**conn_params)
File "/usr/lib64/python2.7/site-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Could you post the full traceback, as well as the cron job itself?
Also, if I understand your question correctly, you are trying to use cron to start your server on boot? If this is the case, you would be better served using something like supervisord to manage your server processes IMO.
Related
I am working on my Django project and I am trying to deploy it on Kubernetes cluster ( Google Cloud Provider ). I've managed to create all the files I need for configuring the cluster:
Django App Deployment + Service .yml files
Postgres DB Deployment + Service + PersistentVolumeClaim ( which dynamicly creates PersistentVolume object and uses PD storage on
cloud nodes by default )+ Secret .yml files
Docker File + Docker Compose ( I dont have much experience with docker so there might be something wrong with them, maybe that is the
issue but I cannot figure it out )
For some reason when i try to apply them my PODs, specifically Django Application PODs, are Crashing in an infinite loop. Also my Postgres Pod is not crashing but it is not running eather.
Can anyone help me figure out what am I doing wrong? Here is my github repo: https://github.com/…/mast…/agents/config/kubernetes/postgres
My best guess is that I did not set DATABASES configuration in settings.py file correct, and that my Django Application cannot find DATABASE HOST specified in settings.py. If anyone has any suggestions please leave a comment.
Here is a picture of my Kubernetes Pod list:
Here is a picture where I've described 1st Pod object:
And here is a picture of one of my nodes described:
* UPDATE *
Here is what my ERROR message looks like when i try to run python src/manage.py runserver:
(web_development) cepa995#cepa995-VirtualBox:~/Agentske_Tehnologije/agents$ python src/manage.py runserver
/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
""")
/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
""")
Performing system checks...
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f6b37e9a9d8>
Traceback (most recent call last):
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 168, in get_new_connection
connection = Database.connect(**conn_params)
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not translate host name "postgres-service" to address: Name or service not known
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run
self.check_migrations()
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/core/management/base.py", line 427, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/migrations/loader.py", line 206, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 61, in applied_migrations
if self.has_table():
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 44, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/backends/base/base.py", line 255, in cursor
return self._cursor()
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/backends/base/base.py", line 232, in _cursor
self.ensure_connection()
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 168, in get_new_connection
connection = Database.connect(**conn_params)
File "/home/cepa995/anaconda3/envs/web_development/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not translate host name "postgres-service" to address: Name or service not known
Your application cannot connect to the database, because your Postgres server cannot start (you have 0/1 pods in Ready state).
You did not publish its Pod events, but I guess the main reason is its volume.
In your Postgres specs, I see you set the volume type to
ReadWriteMany, but Google Cloud does not provide volumes with that type (documentation, path "Access Modes") and, actually, I don't see the reason why you need it. Change the type to ReadWriteOnce and redeploy the database, it should help.
P.S. To get a log of application in a cluster, you can call kubectl logs $podname, it’s much more helpful
P.P.S. When you publish text information, use a text format, please.
I'm sure this is my fault, but my system has been working for months and now does not work. I've looked in Django docs and here on stackoverflow, and I understand the issue that 'connection refused' means nobody is listening on the socket; but I don't understand why, and don't know how to go forward.
I use Vagrant + VirtualBox on a MacPro, and for six months I have been able to create virtual machines and run my app with no problems. I have some VM's where everything works as expected.
On my newly-created Vagrant VM's, I install and configure my django apps and run them using 'python manage.py runserver --settings=mumble.settings.py 0.0.0.0:8000'. Note that this is Django 1.8.3, but again,it works fine on some VM's.
For mysterious reasons, when I create a new vagrant VM and install my django payload (using deploy scripts that haven't changed), and connect to the django server, I get Errno 111 Connection refused:
+ python ./manage.py runserver --settings=mydjango.settings 0.0.0.0:8000
.....
_d^^^^^^^^^b_
.d'' ``b.
.p' `q.
.d' `b.
.d' `b. * Mezzanine 4.0.1
:: :: * Django 1.8.3
:: M E Z Z A N I N E :: * Python 2.7.12
:: :: * MySQL 5.7.18
`p. .q' * Linux 4.4.0-75-generic
`p. .q'
`b. .d'
`q.. ..p'
^q........p^
''''
Performing system checks...
System check identified no issues (0 silenced).
May 31, 2017 - 09:50:50
Django version 1.8.3, using settings 'mydjango.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/vagrant/repos_here/www.mydjango.org/venv/www/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
response = self.get_response(request)
File "/vagrant/repos_here/www.mydjango.org/venv/www/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 204, in get_response
'request': request
File "/usr/lib/python2.7/logging/__init__.py", line 1185, in error
Log 'msg % args' with severity 'ERROR'.
File "/usr/lib/python2.7/logging/__init__.py", line 1193, in error
self._log(ERROR, msg, args, **kwargs)
File "/usr/lib/python2.7/logging/__init__.py", line 1286, in _log
self.handle(record)
File "/usr/lib/python2.7/logging/__init__.py", line 1296, in handle
self.callHandlers(record)
File "/usr/lib/python2.7/logging/__init__.py", line 1336, in callHandlers
hdlr.handle(record)
File "/usr/lib/python2.7/logging/__init__.py", line 759, in handle
self.emit(record)
File "/vagrant/repos_here/www.mydjango.org/venv/www/local/lib/python2.7/site-packages/django/utils/log.py", line 129, in emit
self.send_mail(subject, message, fail_silently=True, html_message=html_message)
File "/vagrant/repos_here/www.mydjango.org/venv/www/local/lib/python2.7/site-packages/django/utils/log.py", line 132, in send_mail
mail.mail_admins(subject, message, *args, connection=self.connection(), **kwargs)
File "/vagrant/repos_here/www.mydjango.org/venv/www/local/lib/python2.7/site-packages/django/core/mail/__init__.py", line 98, in mail_admins
mail.send(fail_silently=fail_silently)
File "/vagrant/repos_here/www.mydjango.org/venv/www/local/lib/python2.7/site-packages/django/core/mail/message.py", line 303, in send
return self.get_connection(fail_silently).send_messages([self])
File "/vagrant/repos_here/www.mydjango.org/venv/www/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages
new_conn_created = self.open()
File "/vagrant/repos_here/www.mydjango.org/venv/www/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 58, in open
self.connection = connection_class(self.host, self.port, **connection_params)
File "/usr/lib/python2.7/smtplib.py", line 256, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.7/smtplib.py", line 316, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python2.7/smtplib.py", line 291, in _get_socket
return socket.create_connection((host, port), timeout)
File "/usr/lib/python2.7/socket.py", line 575, in create_connection
raise err
error: [Errno 111] Connection refused
[31/May/2017 09:50:55]"GET /donate/ HTTP/1.1" 500 59
Things I know:
'python ./manage.py' with no arguments will run fine, and shows the help message.
All forms of addressing the web server will fail:
curl http://localhost:8000
curl http://127.0.0.1:8000
curl http://192.168.33.10:8000
from a browser: http://192.168.33.10:8000
nginx is serving on port 80, no problem
my database is a copy of the production database, and it looks fine through 'mysql'
And here is a weird thing: I brought down the Django tutorial, used the 'runserver' command, and it worked!
[vagrant][~/tmp/django_tutorial/mysite]
$ python manage.py runserver 0.0.0.0:8000
Performing system checks...
System check identified no issues (0 silenced).
May 30, 2017 - 20:36:44
Django version 1.8.3, using settings 'mysite.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
[30/May/2017 20:37:05]"GET / HTTP/1.1" 200 1767
Any suggestions on how to debug this?
The answer has nothing to do with my environment. My co-worker added a name to settings.ADMINS, which had been an empty list before that. When ADMINS is a non-empty list, any error triggers an attempt to send email to all of the email addresses in ADMINS, and my VM was not configured to send email. This is documented but not emphasized. The problem did not happen to my coworker, because that associated changes did not trigger a server error.
I'm running a GAE python application with 3 modules, one module run every half an hour and is in charge of fetching a file form an FTP server, processing it and saving it to CloudStorage.
Recently the communication between my application and the FTP server start failing more often, increasingly until it became unusable.
The FTP server is Highwinds, they did some changes recently, asked me some questions like the ping and traceroute from the instance running the code to their server, but I'm not able to provide that given the GAE restrictions.
I was able to overcome some errors by just repeating the same operation multiple times.
I'm including some error traces at the end of this message.
I would appreciate some help troubleshooting this issue.
files = ftp_service.nlst()
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/ftplib.py", line 509, in nlst
self.retrlines(cmd, files.append)
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/ftplib.py", line 432, in retrlines
conn = self.transfercmd(cmd)
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/ftplib.py", line 371, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/ftplib.py", line 330, in ntransfercmd
conn = socket.create_connection((host, port), self.timeout)
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/socket.py", line 569, in create_connection
raise err
error: [Errno 110] Connection timed out
ftp_service.retrbinary("RETR %s" % file_path, callback=handle_binary)
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/ftplib.py", line 409, in retrbinary
conn = self.transfercmd(cmd, rest)
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/ftplib.py", line 371, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/ftplib.py", line 334, in ntransfercmd
resp = self.sendcmd(cmd)
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/ftplib.py", line 244, in sendcmd
return self.getresp()
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/ftplib.py", line 217, in getresp
raise error_temp, resp
error_temp: 425 Rejected data connection from foreign address 74.125.183.23:53274.
I am testing a sample Django app in Travis CI using a Postgres database. I wrote some basic tests for models that passed successfully on my development environment. When I push the code to Travis the following error occurs:
travis link : https://travis-ci.org/Navajyoth/django-travis/jobs/64052563
github link : https://github.com/Navajyoth/django-travis
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/commands/test.py", line 74, in execute
super(Command, self).execute(*args, **options)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/commands/test.py", line 90, in handle
failures = test_runner.run_tests(test_labels)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/test/runner.py", line 210, in run_tests
old_config = self.setup_databases()
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/test/runner.py", line 166, in setup_databases
**kwargs
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/test/runner.py", line 370, in setup_databases
serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 354, in create_test_db
self._create_test_db(verbosity, autoclobber, keepdb)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 447, in _create_test_db
with self._nodb_connection.cursor() as cursor:
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/base/base.py", line 164, in cursor
cursor = self.make_cursor(self._cursor())
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/base/base.py", line 135, in _cursor
self.ensure_connection()
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
self.connect()
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
self.connect()
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/base/base.py", line 119, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 172, in get_new_connection
connection = Database.connect(**conn_params)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
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?
The command "python manage.py test apps.account --settings=settings.dev" exited with 1.
Done. Your build exited with 1.
Main issues in the above problem.
(1) Unsupported version of PostgreSQL
(2) Removing patch release version from PostgreSQL addon.
It fixed the problem
The build is failing because you are using postgres as a db backend to test your app. The traceback shows psycopg2 is unable to connect on localhost:
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory,async=async)
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`
You should either use sqlite as a db backend or specify correct database connection
parameters in your settings.dev. refer https://docs.djangoproject.com/en/1.8/topics/testing/overview/#the-test-database
I'm trying to create a Django app on Heroku, as detailed by the Heroku/Django Cedar stack tutorial.
I've gotten to the point where I deploy my code on Heroku, but when I run heroku run python appname/manage.py syncdb, I get the following trace:
Traceback (most recent call last):
File "planamo/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/__init__.py", line 308, in cursor
cursor = util.CursorWrapper(self._cursor(), self)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 177, in _cursor
self.connection = Database.connect(**conn_params)
File "/app/.heroku/venv/lib/python2.7/site-packages/psycopg2/__init__.py", line 179, in connect
connection_factory=connection_factory, async=async)
psycopg2.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"?
I don't know what the problem is. What's going on?
Answered my own question: you have to run heroku addons:add shared-database
I just found another cause for this error. Heroku injects code at the end of settings.py file.
If last line of settings.py don't contains a carry return injected code may be ignored.
This is the case of django-social-auth's settings.py file
You can try to add: 'HOST': '127.0.0.1' in your database config in settings.py