• Home
  • LLMs
  • Docker
  • Kubernetes
  • Java
  • Maven
  • About
Apache Solr | Configure Solr to listen on a specific IP address or host name
  1. Configure Solr to listen on a specific IP address or host name

  1. Configure Solr to listen on a specific IP address or host name
    When starting Solr, it will try to detect the IP address of the host where it's running. If you want to configure Solr to use another IP address or host name, you can use "jetty.host" as parameter when starting Solr:
    $ /opt/solr/bin/solr start -c -z "192.168.2.22:2181/solr" -p 8983 -Djetty.host=192.168.2.22

    Setting "jetty.host" might be needed when you cannot access Solr Admin UI or when you get errors when using Solr APIs:
    Exception in thread "main" java.lang.RuntimeException:
    Couldn't initialize a HttpClusterStateProvider (is/are the Solr server(s), [http://192.168.2.22:8983/solr], down?)
        at org.apache.solr.client.solrj.impl.CloudSolrClient$Builder.build
    Caused by: org.apache.solr.client.solrj.SolrServerException: Server refused connection at: http://192.168.2.22:8983/solr
        at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod
        ... 1 more

    You can also set "jetty.host" in the "solr.in.sh" file ("solr.in.cmd" for Windows) by editing the "SOLR_OPTS" environment variable:
    # Anything you add to the SOLR_OPTS variable will be included in the java start command line as-is, in ADDITION to other options.
    # If you specify the -a option on start script, those options will be appended as well. Examples:
    SOLR_OPTS="$SOLR_OPTS -Djetty.host=192.168.2.22"

    Note that you might need to set the "SOLR_HOST" environment variable if you get an error similar to the following:
    java.lang.RuntimeException: Tried fetching cluster state using the node names we knew of, i.e. [127.0.1.1:8984_solr, 127.0.1.1:8983_solr].
    However, succeeded in obtaining the cluster state from none of them.
    If you think your Solr cluster is up and is accessible, you could try re-creating a new CloudSolrClient using working solrUrl(s) or zkHost(s).
        at org.apache.solr.client.solrj.impl.BaseHttpClusterStateProvider.getState(BaseHttpClusterStateProvider.java:104)

    To set "SOLR_HOST", edit the "solr.in.sh" file ("solr.in.cmd" for Windows) and uncomment the "SOLR_HOST" environment variable:
    # By default the start script uses "localhost";
    # override the hostname here for production SolrCloud environments to control the hostname exposed to cluster state
    SOLR_HOST="192.168.2.22"

    Note that Solr will use the hostname of the Solr server as the address of the node when it registers with ZooKeeper.
© 2025  mtitek