Magento search with Elasticsearch or OpenSearch

Magento 2.4 needs Elasticsearch or OpenSearch. Connection refused, an empty reply, security_exception, and a read-only index are four different faults.

Last updated: October 26, 2026

Magento 2.4 will not install or index catalog search without Elasticsearch or OpenSearch. A refused connection, an empty reply, security_exception, and FORBIDDEN/12 are different faults. Read the body of the error before you change Magento. When that body is one long JSON line, paste it into the JSON Formatter and read the reason field.

Illustration of an Elasticsearch JSON body with cluster_block_exception and FORBIDDEN/12.
Illustration. FORBIDDEN/12 is the flood-stage read-only block. This is not a capture from a cluster.

Adobe’s current on-premises table lists OpenSearch 3 for Commerce 2.4.9, and both Elasticsearch 8 and OpenSearch 3 for the 2.4.8 patch line. Cloud has moved harder toward OpenSearch. Match the table for your version instead of keeping whatever 7.x or 8.17 binary happened to be installed last year.

Read the symptom

What you see What it means
curl: (7) Failed to connect to localhost port 9200: Connection refused Nothing is listening. The service is stopped, bound to another interface, or using another port.
Empty reply from server while the port is open A process accepted TCP and closed it. Common when you send HTTP to an Elasticsearch 8 port that expects HTTPS.
security_exception The cluster requires authentication or TLS and the request did not satisfy it.
cluster_block_exception … FORBIDDEN/12/index read-only / allow delete Elasticsearch marked indexes read-only because a node crossed the flood-stage disk watermark.

Java failing to start, then a later empty reply, is the first row followed by a half-started process. Fix startup before you touch Magento config.

See whether the cluster is actually up

curl -sS -D- http://127.0.0.1:9200
curl -sS -k https://127.0.0.1:9200

Elasticsearch 8 enables security and HTTPS by default. A successful body contains "tagline" and a version number. If only the https URL works, Magento’s search hostname, port, and “Enable HTTPS” must match that URL.

php bin/magento config:show catalog/search/engine
php bin/magento config:show catalog/search/elasticsearch7_server_hostname
php bin/magento config:show catalog/search/opensearch_server_hostname

On 2.4.6 and later the engine value is opensearch or an elasticsearch id, and the hostname fields are separate. An old elasticsearch7_* value left behind does not configure an OpenSearch server.

Windows: install Elasticsearch as a service only if you accept the RAM it reserves. A laptop that cannot give the JVM its heap will log a startup failure and never open 9200. Lowering the heap in jvm.options (-Xms and -Xmx together) is the documented way to fit a dev box. It does not fix a cluster that is up but read-only.

Connection refused

  1. Start the service and read its log. On Linux, journalctl -u elasticsearch or journalctl -u opensearch. On Windows, the Elasticsearch log folder next to the install.
  2. Confirm the listen address. A bind of 127.0.0.1 is correct for a local Magento. A bind of a public IP is not required and should not be open to the internet.
  3. Point Magento at that host and port, flush config cache, and reindex only search:
php bin/magento cache:flush config
php bin/magento indexer:reindex catalogsearch_fulltext

security_exception

Create a user that can read and write the Magento indexes, and put that user in Magento’s search configuration (Admin: Stores → Configuration → Catalog → Catalog Search, or config:set for the username and password). Do not turn security off on a server other than a disposable laptop. If you do disable it locally, say so in the install notes so nobody copies that elasticsearch.yml to production.

Test with the same credentials Magento will use:

curl -sS -k -u 'USER:PASSWORD' https://127.0.0.1:9200

A 401 means the password is wrong. A security_exception about indices means the user is authenticated and not allowed to touch that index.

FORBIDDEN/12 read-only

Elastic’s watermark guide describes the flood-stage behavior: at about 95% disk the cluster sets index.blocks.read_only_allow_delete. Deletes of whole indexes are still allowed. Document deletes are not. Magento indexing then fails even though search used to work. The illustrated response uses HTTP 403. Look that code up in the HTTP Status Code Lookup. Here 403 is the read-only block, not an admin login failure.

  1. Free disk on the data node. Deleting a Magento debug index you created on purpose is safer than deleting the cluster.
  2. After disk use falls under the high watermark, Elasticsearch removes the block. If it stays, clear it once:
curl -sS -k -u 'USER:PASSWORD' -X PUT "https://127.0.0.1:9200/_all/_settings" \
  -H 'Content-Type: application/json' \
  -d '{"index.blocks.read_only_allow_delete": null}'

Run that only after you know why the disk filled. Clearing the block on a full disk puts it back on the next write.

  1. Reindex catalog search.

Do not disable cluster.routing.allocation.disk.threshold_enabled to hide the error. Elastic’s own issue discussion notes that turning thresholds off also stops the automatic unlock.

Check the result

  • The version URL returns JSON, not “connection refused” or an empty reply.
  • indexer:reindex catalogsearch_fulltext finishes without cluster_block_exception.
  • A storefront search returns products. An empty search with a green indexer means the query is wrong, not that the port is closed.

If that does not work

  • Magento and the cluster disagree about the index prefix, so Magento is writing an index the user cannot see.
  • You reindexed before the cluster was healthy. Run the search indexer again. Do not run every indexer if only search is broken.
  • Windows memory settings were changed and the service still exits. Read the new log line. “Insufficient memory” after a heap change means the box cannot supply that heap, not that Magento’s config is wrong.

References

On this page

Related guides

Related Articles

Related solutions

Need a tool for this ?

Open the free tools — no signup.

FAQs

Innovative Solutions For Modern Needs
Copyright © 2026 Yallasolve. all rights reserved.