Getting an error when connecting to Octoprint

Hey guys,

So I’m trying to get my Octoprint instance connected up to Home Assistant. In octoprint I have the API turned on with CORS turned off.

Here is my entry in my config file:

octoprint:
  - host: http://killinhassio.duckdns.org
    port: !secret octoprint_port
    api_key: !secret octoprint_API_key
    name: Prusa MK3
    sensors:
      monitored_conditions:
        - 'Current State'
        - 'Temperatures'
        - 'Job Percentage'
        - 'Time Elapsed'
        - 'Time Remaining'

I have tried coping and pasting the URL out of host and adding the Port that I have in my secrets file to the end and I can pull up my octoprint instance, so I know that information is right and I’ve triple checked my API Key.

The error message that I see in my hassio log is

Endpoint: printer Failed to update OctoPrint status. Error: HTTPConnectionPool(host='http', port=80): Max retries exceeded with url: //killinhassio.duckdns.org:{portremoved}/api/printer (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x707db950>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

The error message makes me think DNS or host URL issue, but again, I can copy and past that URL out of my config file and it hits my home network. Not sure what is going on and any help would be appreciated.

Nevermind, I figured this out. Apparently for the host: property it breaks if you include http:// or https://. Removing http:// from the host line and restarting fixed it.

2 Likes

Wow…thanks for this simple fix. Been trying to figure out why I couldn’t connect.

No problem! Glad it helped.

did you configured different port on octoprint? did it work adding below line on configuration.yaml?

port: !secret octoprint_port

Not being successful on my end :frowning:

I have octoprint set up for access outside of my home network. So the port I have in my config here is hidden because it is publicly accessible, but port forwarding maps it to the correct port internally for me.

If you are running Home Assistant on your local network and accessing Octopi running on your local network you should be able to simply your config quite a bit. Something like:

octoprint:
  host: 192.168.1.42 (Your IP address for your Octoprint server)
  api_key: YOUR_API_KEY

by the way, does anyone have octo cam setup on HA? How is it done?