"Max retries exceeded with url (...)" - REST api

I'm working a lot with the Octoprint REST api, and I have stumbled accross this issue quite a few times now;

requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=5000): Max retries exceeded with url: /api/files/local (Caused by NewConnectionError('<ur                     llib3.connection.HTTPConnection object at 0x763f6950>: Failed to establish a new connection: [Errno 111] Connection refused',))

The Raspberry (Pi 3B) running Octoprint requests the Octoprint API quite a lot, and sometimes I get the error above. I have 9 Raspberries running with the exact same code, each on their own printer, but one of the Raspberries keep failing with exactly this error. It happens on none of the others.

First I thought it was a network problem, but now I have come to think that it might just be Octoprint? It's only that one request that fails. I can request anything else perfectly fine, and it's not even the URL I request the most.

I tried switching networks - same thing happened. Restart; same thing happens.

Anyone knows why this is?

Do they all have the same hostname?

Yes they do, although they seem to automatically get an increment number at the end;

(unless my IP-Scanner does that)

Is this a possible issue?

Avahi is the hostname broadcasting service that's running within the OctoPi-imaged setup you've got. Both that client and your DHCP router will attempt to negotiate this between themselves; your router—if it's smart—will say "no" to the eight losers of the let's-get-named-octopi race. And then of course DHCP lease time-to-live is all a part of this so the earlier winner might lose that status at some point.

It's just ugly when you've got nine hosts on the same network with the same name. In South Park terms: you're gonna have a bad time.

Interesting aside: Bruce, meet Bruce

Use sudo raspi-config and change nine hostnames: han, chewbacca, leia, yoda, luke, c3po, r2d2, obiwan, padme.

1 Like

I had two printers doing it today, so on one I tried changing the hostname and restarting it, the other I simply restarted. Both worked afterwards. Now it'll be fun to see which of them (if any) get the error again.

Even though I changed the hostname of the one, there are still 7 other printers with the same hostname, so if it is to blame it should happen again.

From now on we'll make sure all the RPI's generate a custom ID and sets it as hostname, so they should all be unique! Thanks!