Wagtail connection refused, Errno 111, Elastic Search

1,878 views
Skip to first unread message

Edd

unread,
Jan 23, 2016, 4:57:15 PM1/23/16
to Wagtail support

Hi guys,

I'm getting an error trying to use the Wagtail Cookiecutter that I can't navigate around.

Elastic search is saying it's running as expected. I'm not getting any errors installing requirements, manage.py migrate, runserver or logging in. The connection gets refused when I try to save an amendment, publish new page, or add a document. 

Error message below

ConnectionError at /admin/pages/3/edit/

ConnectionError(<urllib3.connection.HTTPConnection object at 0x7f24806e2450>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f24806e2450>: Failed to establish a new connection: [Errno 111] Connection refused)
Request Method:POST
Request URL:http://178.62.41.122:8000/admin/pages/3/edit/
Django Version:1.8.5
Exception Type:ConnectionError
Exception Value:
ConnectionError(<urllib3.connection.HTTPConnection object at 0x7f24806e2450>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f24806e2450>: Failed to establish a new connection: [Errno 111] Connection refused)
Exception Location:/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/http_urllib3.py in perform_request, line 102
Python Executable:/usr/bin/python
Python Version:2.7.6
Python Path:
['/home/sacco',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/home/sacco']
Server time:Sat, 23 Jan 2016 21:14:23 +0000

Traceback

Environment:


Request Method: POST
Request URL: http://178.62.41.122:8000/admin/pages/3/edit/

Django Version: 1.8.5
Python Version: 2.7.6
Installed Applications:
('sacco.home',
 'sacco.search',
 'wagtail.contrib.wagtailsearchpromotions',
 'wagtail.wagtailforms',
 'wagtail.wagtailredirects',
 'wagtail.wagtailembeds',
 'wagtail.wagtailsites',
 'wagtail.wagtailusers',
 'wagtail.wagtailsnippets',
 'wagtail.wagtaildocs',
 'wagtail.wagtailimages',
 'wagtail.wagtailsearch',
 'wagtail.wagtailadmin',
 'wagtail.wagtailcore',
 'modelcluster',
 'compressor',
 'taggit',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'wagtail.wagtailcore.middleware.SiteMiddleware',
 'wagtail.wagtailredirects.middleware.RedirectMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _cache_controlled
  43.             response = viewfunc(request, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/decorators.py" in _wrapped_view
  22.                 return view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/wagtail/wagtailadmin/views/pages.py" in edit
  233.                 submitted_for_moderation=is_submitting,
File "/usr/local/lib/python2.7/dist-packages/wagtail/wagtailcore/models.py" in save_revision
  463.             self.save(update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in inner
  145.                     return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/wagtail/wagtailcore/models.py" in save
  311.         result = super(Page, self).save(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/modelcluster/models.py" in save
  198.         super(ClusterableModel, self).save(update_fields=real_update_fields, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in save
  734.                        force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in save_base
  771.                                    update_fields=update_fields, raw=raw, using=using)
File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py" in send
  201.             response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python2.7/dist-packages/wagtail/wagtailsearch/signal_handlers.py" in post_save_signal_handler
  24.             backend.add(indexed_instance)
File "/usr/local/lib/python2.7/dist-packages/wagtail/wagtailsearch/backends/elasticsearch.py" in add
  629.         self.es.index(self.es_index, mapping.get_document_type(), mapping.get_document(obj), id=mapping.get_document_id(obj))
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/utils.py" in _wrapped
  69.             return func(*args, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/__init__.py" in index
  261.             _make_path(index, doc_type, id), params=params, body=body)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/transport.py" in perform_request
  329.                 status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/http_urllib3.py" in perform_request
  102.             raise ConnectionError('N/A', str(e), e)

Exception Type: ConnectionError at /admin/pages/3/edit/
Exception Value: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7f24806e2450>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f24806e2450>: Failed to establish a new connection: [Errno 111] Connection refused)


Any ideas?

Thanks
Edd

Brett Grace

unread,
Jan 23, 2016, 5:46:55 PM1/23/16
to Wagtail support
Sure looks like Elasticsearch isn't listening on the expected port to me. What did you do to determine that Elasticsearch is running—are you able to telnet or curl against localhost:9200 when logged into the box? If you're not sure how to do that, what do you get if you run lsof -i tcp | grep LISTEN on the Linux box? (This command may take a minute to compete).

Edd Baldry

unread,
Jan 24, 2016, 12:11:25 PM1/24/16
to wag...@googlegroups.com
Hi Brett,

Thanks so much for the quick response. You were absolutely right! The issue was with ElasticSearch. Slightly embarrassingly I had restored an old snapshot on my digital ocean box without a java environment, once installed ElasticSearch has started running as normal (e.g. I get a response if I run curl -X GET 'http://localhost:9200'). Thanks for the help though with lsof -i tcp | grep LISTEN, that headed me in the right direction. 

One final question, since elasticsearch needs a java environment to run correctly shouldn't pip install -r requirements.txt have returned some sort of error or alert? (Though it's entirely possible it did and I just missed it)

Thanks
Edd
-



--
You received this message because you are subscribed to a topic in the Google Groups "Wagtail support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wagtail/z-H0Bsq0bHE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wagtail+u...@googlegroups.com.
To post to this group, send email to wag...@googlegroups.com.
Visit this group at https://groups.google.com/group/wagtail.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wagtail/4d89b683-9a69-43ec-b432-22290b6bae31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Edd Baldry
+44(0)790 999 1778

Brett Grace

unread,
Jan 24, 2016, 12:33:35 PM1/24/16
to Wagtail support
This isn't something I would expect pip to do. The "elasticsearch" library you install is a pure Python client, with no Java dependencies—it has no that you need a working Elasticsearch on the same machine (you could, after all, be talking to an ES instance on another machine). Generally speaking, though, pip will install Python libraries and it can build native extensions from source, but if those extensions depend on something already existing in the environment (things like header files, etc.) pip on its own will not get them for you. That requires making too many assumptions about the environment and pip isn't a general purpose package manager (like apt-get) or a configuration management system (like Ansible, Chef, etc.). For example, think how many Java distributions there are (JDK version * JDK vendor * Operating System)—those aren't decisions I want pip making for me.

If the Cookiecutter script didn't install Elasticsearch, however, that seems like an omission that should be documented or fixed (if the default settings module expects it).

Gary Rojas

unread,
Feb 16, 2016, 3:01:25 AM2/16/16
to Wagtail support
I'm having the same problem about: Failed to establish a new connection: [Errno 111] Connection refused
Could you solve it?

Thanks in advanced for your answer.

Regards,
Gary Rojas 

Brett Grace

unread,
Feb 16, 2016, 11:03:52 AM2/16/16
to Wagtail support
Assuming the problem is arising from the search code, it means ElasticSearch isn't reachable (most likely, it isn't running, but possibly it's running but you haven't configured Wagtail to be able to find it). This is just like if you try to start up Wagtail without PostgreSQL or MySQL running, you'll get an error when you try to start up Django.

There isn't a general solution since there are many reasons ElasticSearch might not be running. You'll need to follow the installation steps and troubleshooting guide for ElasticSearch. If you can describe exactly what you did to install and start ElasticSearch, perhaps I or somebody else might see the problem, but it isn't a Wagtail issue per se and you may need to seek help on support channels dedicated to ElasticSearch.

If you don't actually need ElasticSearch, you can sidestep the issue by changing your configuration to use the database backend.
Reply all
Reply to author
Forward
0 new messages