Short answer

“Expected mime type application/octet-stream but got text/html” means DSpace asked Solr for one of its cores and got Solr’s HTML error page back. Either the DSpace cores were never copied into Solr, or solr.server points to the wrong address. Copy the cores from /dspace/solr, or fix solr.server to end in /solr.

Tested on Ubuntu 26.04 and 24.04, two separate runs. On 24.04, every step is the same. Everything that differed

This lesson starts from a DSpace server set up as in Install DSpace: Solr 9 on localhost:8983, DSpace in /dspace. On the test server each cause below was made on purpose, then fixed.

Where you see it

Rebuilding the search index stops with it (the first lines; a long Java stack trace follows):

Server
$ sudo -iu dspace /dspace/bin/dspace index-discovery -bThe script has started(Re)building index from scratch.org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/solr/search: Expected mime type application/octet-stream but got text/html. <!--[… 37 lines not shown …]
Output hidden (4 lines)

The web interface’s searches and browse pages fail, because they call the same search through the REST API. Without a browser, its status shows it: 400 instead of 200:

Server
$ curl -s -o /dev/null -w "%{http_code}\n" "http://localhost:8080/server/api/discover/search/objects?query=*"400
Output hidden (1 line)

And DSpace’s log has the message:

Server
$ grep -m 1 -o 'Expected mime type[^;]*' /dspace/log/dspace.logExpected mime type application/octet-stream but got text/html. <!--
Output hidden (1 line)

Cause 1: the DSpace cores are not in Solr

DSpace keeps its search data in Solr “cores” named search, statistics, oai and a few more. They ship in /dspace/solr and must be copied into Solr’s data folder once, after the install. List the cores Solr has:

Server
$ curl -s 'http://localhost:8983/solr/admin/cores?action=STATUS&wt=json' | grep -o '"name":"[a-z]*"' | sort

It prints nothing: Solr is running but has none of DSpace’s cores. Asking for one shows what DSpace received: a 404 error page, as HTML. DSpace expected Solr’s binary answer (application/octet-stream), hence the message:

Server
$ curl -s -o /dev/null -w '%{http_code} %{content_type}\n' 'http://localhost:8983/solr/search/select?q=*:*'404 text/html
Output hidden (1 line)

The fix: copy the cores into Solr, give them to the solr user and restart Solr:

Server
$ sudo cp -R /dspace/solr/* /var/solr/data/ && sudo chown -R solr:solr /var/solr/data && sudo systemctl restart solr

Now the list has search and the others, and the index builds:

Server
$ curl -s 'http://localhost:8983/solr/admin/cores?action=STATUS&wt=json' | grep -o '"name":"[a-z]*"' | sort"name":"audit""name":"authority""name":"oai""name":"qaevent""name":"search""name":"statistics""name":"suggestion"
Output hidden (7 lines)
Server
$ sudo -iu dspace /dspace/bin/dspace index-discovery -bThe script has started(Re)building index from scratch.Done with indexingThe script has completed
Output hidden (4 lines)

Cause 2: solr.server does not end in /solr

DSpace’s default is http://localhost:8983/solr, set in dspace.cfg. local.cfg only has it commented out, and a line you set there wins. Look in both:

Server
$ grep -n "solr.server = " /dspace/config/dspace.cfg /dspace/config/local.cfg/dspace/config/dspace.cfg:56:solr.server = http://localhost:8983/solr/dspace/config/local.cfg:69:#solr.server = http://localhost:8983/solr
Output hidden (2 lines)

On the test server a line without /solr was then added to local.cfg, the usual typo:

Server
$ grep -n "^solr.server" /dspace/config/local.cfg244:solr.server = http://localhost:8983
Output hidden (1 line)

The same message, for a different reason: DSpace now asks http://localhost:8983/search, and Solr’s web server answers that address with its HTML “Error 404 Not Found” page.

Server
$ sudo -iu dspace /dspace/bin/dspace index-discovery -bThe script has started(Re)building index from scratch.org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/search: Expected mime type application/octet-stream but got text/html. <html><head><meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/><title>Error 404 Not Found</title>[… 28 lines not shown …]
Output hidden (7 lines)

The fix: correct the line in local.cfg (or delete it, so the default applies), then restart the backend so the web interface’s searches use the new setting too:

Server
$ sudo -u dspace sed -i 's|^solr.server = .*|solr.server = http://localhost:8983/solr|' /dspace/config/local.cfg && grep -n "^solr.server" /dspace/config/local.cfg244:solr.server = http://localhost:8983/solr
Output hidden (1 line)
Server
$ sudo systemctl restart dspace
Server
$ sudo -iu dspace /dspace/bin/dspace index-discovery -bThe script has started(Re)building index from scratch.Done with indexingThe script has completed
Output hidden (4 lines)

Not this error: Solr is not running

When Solr is stopped, DSpace prints “Failed to contact Solr … Server refused connection” instead of the mime-type message:

Server
$ sudo -iu dspace /dspace/bin/dspace index-discovery -bThe script has started(Re)building index from scratch.java.lang.RuntimeException: Failed to contact Solr at http://localhost:8983/solr/search :  Server refused connection at: http://localhost:8983/solr/search	at org.dspace.discovery.SolrSearchCore.initSolr(SolrSearchCore.java:109)[… 9 lines not shown …]
Output hidden (5 lines)
Server
$ systemctl is-active solrinactive
Output hidden (1 line)
Server
$ sudo systemctl start solr && systemctl is-active solractive
Output hidden (1 line)

Check it worked

Server
$ sudo -iu dspace /dspace/bin/dspace index-discovery -bThe script has started(Re)building index from scratch.Done with indexingThe script has completed
Output hidden (4 lines)
Server
$ curl -s -o /dev/null -w "%{http_code}\n" "http://localhost:8080/server/api/discover/search/objects?query=*"200
Output hidden (1 line)

200: the search the web interface uses works again.

Troubleshooting

  • Expected mime type application/octet-stream but got text/html and no search core: copy the cores from /dspace/solr. Details.
  • The same message and the cores are there: solr.server in local.cfg is wrong; it must end in /solr. Details.
  • Failed to contact Solr at http://localhost:8983/solr/search : Server refused connection: Solr is not running; start it. Details.

What these steps changed on the server

Both runs recorded the server before the first step and after the last (see the Tested on box below). The fixes put the server back as lesson 1 left it: the cores in Solr, solr.server correct, Solr running.

Ubuntu 26.04 vs 24.04

The same check ran on a fresh 26.04 server and on a fresh 24.04 server, each with its own run log. Every command printed exactly the same on both.

WhatUbuntu 26.04Ubuntu 24.04
SystemUbuntu 26.04 LTS7.0.0-29-genericUbuntu 24.04.4 LTS6.8.0-137-generic
openjdk-21-jdk-headless21.0.13.1+2-1~26.04.121.0.13.1+2-1~24.04.1
maven3.9.12-1not installed
ant1.10.15-1build11.10.14-1
postgresql-1717.12-1.pgdg26.04+1not installed
dspace10.110.1
solr9.11.09.11.0
postgresql-16not installed16.15-0ubuntu0.24.04.1
Commands and resultsThe same on every release: the same commands, the same results.
ProofRun log, 42 checks passedRun log, 42 checks passed