1

I'm trying to automate the creation of new collections using the solr create command in Solr 8.11.1 as follows

sudo -u solr /opt/solr/bin/solr create -c collection_name

However, I get connection refused since Solr is listening on the host IP address, not localhost

ERROR: Connect to localhost:8983 [localhost/127.0.0.1] failed: Connection refused (Connection refused)

Is there a way to specify a hostname/IP address when running solr create?

drjeep
  • 1,019
  • 2
  • 9
  • 15
  • I'm using vagrant to automate the CKAN instance creation. And you? Could you please help me to solve my problem, that seems just about the same as yours? Obs.: I put my [question here](https://stackoverflow.com/questions/76972745/connection-refused-when-running-solr-create-from-vagrant-provision-file). – Gabriel Braico Dornas Aug 24 '23 at 20:41

1 Answers1

1

You can set the hostname used for the bin/solr script through the SOLR_HOST environment variable:

export SOLR_HOST=<ip>
sudo -u solr /opt/solr/bin/solr create -c collection_name
MatsLindh
  • 49,529
  • 4
  • 53
  • 84
  • I tried this before posting and it didn't work, but in hindsight it's because `SOLR_HOST` is not passed through to the sudo user. This appears to work, though `sudo -u solr SOLR_HOST= /opt/solr/bin/solr create -c collection_name` – drjeep Jun 23 '22 at 08:14
  • I tried this with export and directly during the command call, but nothing worked. I tried many IP addresses as well. After try tons of things I also write [this stackoverflow question](https://stackoverflow.com/questions/76972745/connection-refused-when-running-solr-create-from-vagrant-provision-file) cound you guys help me? – Gabriel Braico Dornas Aug 24 '23 at 20:37