FarmBot Local API Troubleshoot

Hi Rick,

My name is Brennan. I’m one of the fall interns working with the food production team at KSC. I’ve been working on provisioning FarmBot using your guide and it looks like the API is running successfully so far. I’m running it via Linux Ubuntu 16.04 on VirtualBox. I have no previous experience working with VMs or running private servers, so please forgive me if I say anything wrong.

It also looks like the MQTT is communicating with the API (I can see the API terminal responding to the MQTT, and in the MQTT terminal it is saying:
Downloaded certificate from http://localhost:3000/api/public_key

When I open the web app in the browser at localhost:3000 it looks right, but displays an error saying that the web browser is unable to connect to the message broker.
In the top right, of the browser in the app, it says FarmBot is disconnected. FarmBot is plugged in and appears to be on, so I’m not sure where the problem lies. Obviously, none of the controls produce any physical response from FarmBot.

If you have any suggestions on where the problem is or how to troubleshoot, please let me know!

Thanks for your help,
Brennan Cordova

Hi Brennan,

It’s great to hear from folks at the KSC.

A few things:

  • I would avoid using localhost as an IP address when using a virtual machine. Use the real IP address of your machine inside of application.yml for the API_HOST entry.
  • Once you change your host, and reboot all services, if it is still having issues, please send me a screen shot of your Javascript console (ctrl + shift + j on most machines).


Edit: You will also need to update MQTT_HOST as well.

Okay awesome, thanks! I’m trying that now.

Are you saying both the MQTT_HOST and API_HOST should have the same IP address?
The address I input for both of these was found simply using the arp -a command in the terminal.

Not always, but in your case, I think so. You are running MQTT and Web on the same machine, correct? If that’s the case, then they will have the same IP. Some users will host the MQTT server on different machines.

Here’s a few things you can try:

  1. Run rails c inside of the VM from the directory of the web app.
  2. Type ENV.fetch("API_HOST") and ENV.fetch("MQTT_HOST") inside the console. Do they show IP addresses?

Other things that are helpful for debugging:

  • Run git log -1 --pretty=format:"%x09%ad%x09" in the API directory. It will show the version you are running on. What date does it show?
  • A screen shot of your connectivity panel (example below) would be helpful.
  • A screen shot of your Javascript console would also be helpful (ctrl + shift + j)

Yes, both of the ENV.fetch show the same IP address that I input into the host entries. I am running both from the same machine, so that makes sense.

Running the git command gives me:
Mon Oct 23 09:41:14 2017 -0500

Here is the connectivity panel from before:

I have updated both API_HOST and MQTT_HOST with the IP address of the VM. I did this and started up the API with “rails api:start” and the MQTT with “WEB_API_URL=http://localhost:3000 npm start”

This gave me the same error when loading the page, but this time the page would not load.

I tried again running the api with:

MQTT_HOST=xx.x.x.x rails s

and running the MQTT with:

WEB_API_URL=http://xx.x.x.x:3000 npm start

This time it could not download the certificate and when I navigated to the webpage it did not load correctly.

I would recommend using the Chrome web browser; the browser in the screenshots may be causing the message broker connection issue.

If you still encounter problems, there are some debugging tips for a similar issue in this post.

Also, if the page doesn’t load completely, try logging out and back in.

I initially thought you were running an older version of the app, but it seems that you are on a quite recent version (23 October).

Here are some things to try:

  • We stopped using WEB_API_URL=http://localhost:3000 npm start to run the message broker this month. The new way to run the message broker is to run rails mqtt:start from the same directory as the web app. Here are some setup instructions that I manually tested 20 minutes ago on an Ubuntu 17 box.
  • As for the Webpack::Rails::Manifest error, there may be some other issue. I think you may have been looking at old documentation, as your server is not using Foreman, which was added in the last 4 months or so. Try running your server with rails api:start instead of rails s.

Thanks for all the details provided. Also, as @Gabriel has already mentioned, it is best to use Chrome until you are certain that all the servers are running. Some browsers have issues with WebSockets, which are required for FarmBot.

Wow, thanks so much Rick. I’m gonna work on this throughout the weekend and I’ll let you know if I run into any more issues. It looks like my computer doesn’t support VT-x/AMD-v visualization needed for running Ubuntu 64 bit, so I’ve been running the 32 bit version, which Chrome doesn’t support anymore. I’ll try to find a workaround for this or try out some other browsers, and update for the new setup.

Thanks again for all your help!

1 Like

I’ve got the same issue like BrennanNASAveggie. Tried Firefox, Chrome and Chromium and everywhere this error comes up when opening the address Websockettest shows that they are working fine.

I just noticed that there is some kind of an error when the webpack is beeing started:


Is it safe to assume you ran yarn install during setup?

It looks like webpack-dev-server can’t be found in your node_modules directory. This is probably fixable via yarn add webpack-dev-server@2.9.3, but ideally, you should not need to do that during setup.

If you did run yarn install during setup, were there any other steps you had to take during setup? Please let me know and I can look into a fix for any other users that are facing the same issue.

Thanks @RickCarlino, running yarn install was the solution, even though I’m pretty sure that I did this before.
I was following all the steps in your file but got stuck at running gem install bundler. There was an error message that “gem” is not a function and ruby is not installed. So I had to run rvm --default use 2.4.2 what somehow made it work.

Everything seems to run fine now. I’m using VirtualBox V5.1.23 and Ubuntu 17.04 64-bit. All browsers Firefox, Chrome and Chromium work for me.

If you’ve got the same log message in the terminal when starting the API, check your Farmbot-Web-App/node_modules/ folder. In my case there was nothing inside before running yarn install again.

Also if your mqtt broker doesn’t connect (econnrefused), you may have to use at API_HOST and MQTT_HOST at your application.yml file.

Hey Rick,

Still running into some issues, and I believe it has to do with a problem in the docker install. After installing the pre-reqs for docker and entering curl -fsSL | sudo apt-key add - I receive error:

curl: (6) Could not resolve host:
gpg: no valid OpenPGP data found.

I can’t tell if this is an issue with the repository or something on my end. I’ve been looking for another way to install but nothing is working. Any suggestions?

Docker is only needed for the next version of the message broker, which we’re still working on with regards to self-hosted setups.

For now, I recommend using the old message broker, which can be set up via npm install and run with npm start after starting the web app.


I tried this and ran npm install successfully, but I cannot run npm start like this at all, even with the web app running. I continue to get the message ===We use 'rails api:start' now.=== although I am already running this command.

rails mqtt:start also does not work

npm install and npm start should be run in the mqtt-gateway directory.

Okay, I ran npm install successfully in the mqtt-gateway directory, and now can run npm start in mqtt-gateway and rails api:start in Farmbot-Web-App directory, but I now receive the same error from the web app that I did in my initial post:

“Your web browser is unable to connect to the message broker.”

Updated list of things tried:

  • Updated API_HOST and MQTT_HOST to VM IP address in application.yml.
  • Installed Chrome and Chromium to attempt running with different browser
  • Reinstalled MQTT and ran via npm start
  • Ran via npm run dev to try on default port

In Chrome you can use Ctrl + Shift + J to open the JavaScript console and enter store.getState().auth.token.unencoded.mqtt to check the MQTT IP address. The returned value should be the same as MQTT_HOST, of the form "". Do you see any errors in the console like WebSocket connection to . . . failed? This would probably mean an address configuration issue, possibly related to the VM. Have you tried both "" and "" for MQTT_HOST?