Anaconda incorrectly overwrites the $HOST variable which seems to be caused by this anaconda bug. It exports x86_64-conda_cos6-linux-gnu as the HOST. This probably occurs only when ran inside .bashrc to initialize the terminal. Simply exporting localhost as the host, mostly fixes it e.g.:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/kmourat/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
    if [ -f "/home/kmourat/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/kmourat/anaconda3/etc/profile.d/conda.sh"
        export PATH="/home/kmourat/anaconda3/bin:$PATH"
unset __conda_setup
# <<< conda initialize <<<

export HOST=localhost

But is there a more appropriate way to do this? Something like "re-running" the /etc/hosts?

(This came out when running npm start for a react app and it opened a browser window at http://x86_64-conda_cos6-linux-gnu:3000/ instead of http://localhost:3000/)

  • export HOST=$(hostname) maybe? – steeldriver Jun 13 at 17:27
  • If anaconda's init messes with other environment variables from /etc/hosts does this fix reset them as well (some side-effect maybe?), or it just changes the HOST? Edit: It seems it doesn't, only overwrites the host variable, which doesn't seem better to me as localhost ends up not pointing to same place as $hostname. – Kostas Mouratidis Jun 14 at 5:04
  • Save the value of $HOST before running anaconda in another variable (e.g. $hosttemp) and reassign it afterwards. – noeppi noeppi Jun 14 at 18:25
  • The old host only holds "localhost", but I guess this is the correct answer. Even more so since it is simple, and it seems too tedious to check all variables for side-effects. – Kostas Mouratidis Jun 14 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.