title: How to fix "elasticsearch.exceptions.AuthenticationException: ... missing authentication token for REST request"?
body: <p>I am working on using an ElasticSearch database to store data I am pulling from online. However, when I try to index the data in the database I receive an error.</p>
  <p>Here is my code for creating and indexing the data:</p>
  <pre><code>es = Elasticsearch()
  
  es.index(index='weather', doc_type='data', body=doc)
  </code></pre>
  <p>However when I run this program, the second of those lines causes an error, here is the complete traceback:</p>
  <pre><code>Traceback (most recent call last):
  File &quot;weatherScraper.py&quot;, line 79, in &lt;module&gt;
    main()
  File &quot;weatherScraper.py&quot;, line 73, in main
    es.index(index='weather', doc_type='data', body=doc)
  File &quot;/home/alec/.local/lib/python2.7/site-packages/elasticsearch/client/utils.py&quot;, line 73, in _wrapped
    return func(*args, params=params, **kwargs)
  File &quot;/home/alec/.local/lib/python2.7/site-packages/elasticsearch/client/__init__.py&quot;, line 298, in index
    _make_path(index, doc_type, id), params=params, body=body)
  File &quot;/home/alec/.local/lib/python2.7/site-packages/elasticsearch/transport.py&quot;, line 312, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File &quot;/home/alec/.local/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py&quot;, line 128, in perform_request
    self._raise_error(response.status, raw_data)
  File &quot;/home/alec/.local/lib/python2.7/site-packages/elasticsearch/connection/base.py&quot;, line 125, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
  elasticsearch.exceptions.AuthenticationException: TransportError(401, u'security_exception', u'missing authentication token for REST request [/weather/data]')
  </code></pre>