Hostname in MarkLogic
25 June 2021 05:04 PM

Where does the hostname come from?

  • If there is a MARKLOGIC_HOSTNAME environmental variable, it is used as the hostname
  • If there is no environment variable configured, the gethostname() library function is called (instead of the gethostname() system call since we use the GNU C Library - see notes here for more info) which internally calls uname() function 
    • This uname() function looks for and returns the nodename which does or does not have a '.' in it (you can also get the output of the uname() call by running the uname --nodename command on the terminal)
      • If the response from the uname() call has a '.' in it, we consider it a complete name and use it as the hostname
      • Otherwise, we look at the resolv.conf for a domain entry/search entry and we take the first entry and to get the complete hostname, we add this entry from resolv.conf to the uname output from the above step followed by a '.' and use that as a hostname
        • E.g.: <uname_output>.<resolv.conf_entry>
        • Note: the resolv.conf file could have both a domain and a search entry and usually domain entry takes priority over search


If you experience a hostname mismatch or any hostname issue in general, you can check the following:

  • The following commands/functions are different ways to return the hostname (and you can verify if there is a mismatch)
    • Functions:
    • Commands:
      • hostname
      • hostname -f  (returns FDQN with '.')
      • hostname -d  (lists all the domains)
  • Check the resolv.conf file (under /etc) to see if it contains the right hostname
    • If yes and the issue still persists, restarting ML server would help because if ML is getting the hostname from this file, it will do so at startup

Note: When you want to open a support ticket in this context, attaching the above information (the outputs of the above commands/functions and the contents of resolv.conf file) along with it would help speed up the investigation

Possible issues with hostname mismatch:

(1 vote(s))
Not helpful

Comments (0)