0

I have setup an elastic beanstalk instance with Django and am trying to use Apache Solr to index products in the application. Solr is running as a background process as per this question, but the server is returning a 500 error for all requests. Looking at the logs in /etc/httpd/error_log, there is an error:

Failed to query Solr using '*:*': Failed to connect to server at 'http://127.0.0.1:8983/solr/select/?facet.query=price...' 
('connection aborted.', error(111, 'Connection refused'))

In my Django settings.py, I have the haystack settings for Solr as follows: (from here)

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        'URL': 'http://127.0.0.1:8983/solr',
        'INCLUDE_SPELLING': True,
    },
}

Looking at the code for Solr on github:

        try:
            raw_results = self.conn.search(query_string, **kwargs)
        except (IOError, SolrError), e:
            if not self.silently_fail:
                raise
            self.log.error("Failed to query Solr using '%s': %s", query_string, e)
        raw_results = EmptyResults()

I checked the security group settings on AWS, and the group accepts inbound traffic on port 8983 (from within that group). Also, I ssh into the EC2 instance, and the Solr java process is running in the background. Looking at this post, it seems that Haystack is defaulting to the local Database settings, and not the AWS Elastic Beanstalk settings.

if 'RDS_DB_NAME' in os.environ:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': os.environ['RDS_DB_NAME'],
            'USER': os.environ['RDS_USERNAME'],
            'PASSWORD': os.environ['RDS_PASSWORD'],
            'HOST': os.environ['RDS_HOSTNAME'],
            'PORT': os.environ['RDS_PORT'],
        }
    }
else:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': 'hhwc',
            'HOST': 'localhost',
            'PORT': '5432',
        }
    }

What could cause this 500 server error (connection error with Solr)?

Community
  • 1
  • 1
Tui Popenoe
  • 2,098
  • 2
  • 23
  • 44

0 Answers0