Update: I restarted the pi and everything works fine, but how can I keep it from failing?