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):
$ 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 …]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:
$ curl -s -o /dev/null -w "%{http_code}\n" "http://localhost:8080/server/api/discover/search/objects?query=*"400And DSpace’s log has the message:
$ grep -m 1 -o 'Expected mime type[^;]*' /dspace/log/dspace.logExpected mime type application/octet-stream but got text/html. <!--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:
$ curl -s 'http://localhost:8983/solr/admin/cores?action=STATUS&wt=json' | grep -o '"name":"[a-z]*"' | sortIt 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:
$ curl -s -o /dev/null -w '%{http_code} %{content_type}\n' 'http://localhost:8983/solr/search/select?q=*:*'404 text/htmlThe fix: copy the cores into Solr, give them to the solr user and restart Solr:
$ sudo cp -R /dspace/solr/* /var/solr/data/ && sudo chown -R solr:solr /var/solr/data && sudo systemctl restart solrNow the list has search and the others, and the index builds:
$ 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"$ sudo -iu dspace /dspace/bin/dspace index-discovery -bThe script has started(Re)building index from scratch.Done with indexingThe script has completedCause 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:
$ 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/solrOn the test server a line without /solr was then added to local.cfg, the usual typo:
$ grep -n "^solr.server" /dspace/config/local.cfg244:solr.server = http://localhost:8983The 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.
$ 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 …]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:
$ 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$ sudo systemctl restart dspace$ sudo -iu dspace /dspace/bin/dspace index-discovery -bThe script has started(Re)building index from scratch.Done with indexingThe script has completedNot 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:
$ 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 …]$ systemctl is-active solrinactive$ sudo systemctl start solr && systemctl is-active solractiveCheck it worked
$ sudo -iu dspace /dspace/bin/dspace index-discovery -bThe script has started(Re)building index from scratch.Done with indexingThe script has completed$ curl -s -o /dev/null -w "%{http_code}\n" "http://localhost:8080/server/api/discover/search/objects?query=*"200200: the search the web interface uses works again.
Troubleshooting
Expected mime type application/octet-stream but got text/htmland nosearchcore: copy the cores from/dspace/solr. Details.- The same message and the cores are there:
solr.serverinlocal.cfgis 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.
| What | Ubuntu 26.04 | Ubuntu 24.04 |
|---|---|---|
| System | Ubuntu 26.04 LTS7.0.0-29-generic | Ubuntu 24.04.4 LTS6.8.0-137-generic |
| openjdk-21-jdk-headless | 21.0.13.1+2-1~26.04.1 | 21.0.13.1+2-1~24.04.1 |
| maven | 3.9.12-1 | not installed |
| ant | 1.10.15-1build1 | 1.10.14-1 |
| postgresql-17 | 17.12-1.pgdg26.04+1 | not installed |
| dspace | 10.1 | 10.1 |
| solr | 9.11.0 | 9.11.0 |
| postgresql-16 | not installed | 16.15-0ubuntu0.24.04.1 |
| Commands and results | The same on every release: the same commands, the same results. | |
| Proof | Run log, 42 checks passed | Run log, 42 checks passed |
