1
votes

Error info:

Exception Type: ConnectionError at /admin/items/country/add/
Exception Value: ConnectionError (<urllib3.connection.HTTPConnection 
object at 0x111377110>: Failed to establish a new connection: [Errno 
61] Connection refused) caused by: 
NewConnectionError(<urllib3.connection.HTTPConnection object at 
0x111377110>: Failed to establish a new connection: [Errno 61] 
Connection refused)

I am getting this connection error while saving the post from Django admin. I have a MYSQL database with settings

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mystic_db',
        'USER': 'root',
        'PASSWORD': '*****',
        'HOST': '',
        'PORT': '',

I am a newbie to Django Python. kindly request a solution to this issue ?

Traceback:

File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 132. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper 616. return self.admin_site.admin_view(view)(*args, **kwargs) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view 110. response = view_func(request, *args, **kwargs) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 57. response = view_func(request, *args, **kwargs) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner 233. return view(request, *args, **kwargs) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/contrib/admin/options.py" in add_view 1516. return self.changeform_view(request, None, form_url, extra_context) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper 34. return bound_func(*args, **kwargs) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view 110. response = view_func(request, *args, **kwargs) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func 30. return func.get(self, type(self))(*args2, **kwargs2) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/utils/decorators.py" in inner 145. return func(*args, **kwargs) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/contrib/admin/options.py" in changeform_view 1467. self.save_model(request, new_object, form, not add) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/contrib/admin/options.py" in save_model 1078. obj.save() File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/db/models/base.py" in save 710. force_update=force_update, update_fields=update_fields) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/db/models/base.py" in save_base 747. update_fields=update_fields, raw=raw, using=using) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/django/dispatch/dispatcher.py" in send 201. response = receiver(signal=self, sender=sender, **named) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/haystack/signals.py" in handle_save 52. index.update_object(instance, using=using) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/haystack/indexes.py" in update_object 284. backend.update(self, [instance]) File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py" in update 190. bulk(self.conn, prepped_docs, index=self.index_name, doc_type='modelresult') File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/elasticsearch/helpers/init.py" in bulk 188. for ok, item in streaming_bulk(client, actions, **kwargs): File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/elasticsearch/helpers/init.py" in streaming_bulk 160. for result in _process_bulk_chunk(client, bulk_actions, raise_on_exception, raise_on_error, **kwargs): File "/Users/MacbookAir/myproject/lib/python2.7/site-packages/elasticsearch/helpers/init.py" in _process_bulk_chunk 89. raise e

Exception Type: ConnectionError at /admin/items/country/add/
Exception Value: ConnectionError (<urllib3.connection.HTTPConnection 
object at 0x111377110>: Failed to establish a new connection: [Errno 
61] Connection refused) caused by: 
NewConnectionError(<urllib3.connection.HTTPConnection object at 
0x111377110>: Failed to establish a new connection: [Errno 61] 
Connection refused)
2

2 Answers

1
votes

i assume your database is hosted locally

so try changing this in your settings file for the database

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mystic_db',
        'USER': 'root',
        'PASSWORD': '*****',
        'HOST': '127.0.0.1', or localhost whatever you prefer
        'PORT': '',
}
}
1
votes

This was a problem because of improper installing of elastic search which I was using along with haystack module. Elastic search is built using Java, and requires at least Java 8 in order to run. Once I installed the same, the connection error urllib3.connection.HTTPConnection got alright.