set API_ROOT from env
Handle case when server goes away