Cannot start Octoprint automatically

Hello everyone.

one month ago i bought my first 3d printer, and already had a lot of fun with it. Now i want to try controlling it from an raspberry pi4, so ik have raspbian with octoprint installed, according foosels guide.

until i reached this step:

You should then be able to start the OctoPrint server:

pi@raspberrypi ~ $ ~/OctoPrint/venv/bin/octoprint serve
 * Running on

When i type that command, the terminal returns: No such file or directory.
So I looked with the file browser in the bin folder, and indeed there is not such a file, also not hidden.

but the strange thing is, i am able to start octoprint in this way:

cd OctoPrint
cd venv
cd bin
octoprint serve

This method works fine, octoprint starts, and i can connect using the browser.
I can connect to printer, control it, and upload and print gcode files.

So i thought, octoprint is working fine, so i continued to the automatic startup section in the guide.
Followed every step, deleted the # in front of deamon, but i cannot get it to work.

I cannot start octoprint with:

sudo service octoprint start

And also, octoprint does not start automatically.

The first problem didn't really bother me, because octoprint worked fine.
But when the autostart didn't work, i started to think these two problems are related to eachother.

I already checked to logfile, cut the moment the autostart should occur, there is nothing in the logfile. I started the pi this moring around 7:30am. At 8:43am i started it manualy, which is in the logfile attached.
octoprint.log (37.6 KB)

Is there any one who can help me with this problem?

You say the doublequoted stuff above didn't work. I assume those two lines are from the intruction manual, as it shows that it is running correctly.

So, what exact command did you type? Copy and paste the exact command you typed and the exact error you got.

You say you can't start it like that, what error(s) do you get? Again, copy and paste the exact command and errors.

After doing this sudo service command above, immediately run and save the output from tail /var/log/daemon.log.

tedder42, thanks for your reply.

I copied that from the manual indeed.

I did the command again, and also tried to start the service and tail log command.

Here is the screenshot with my commands and the responses:

for fun, show the output from this:
ls -l ~/OctoPrint/venv/bin/

Please copy text rather than giving a screenshot.

1 Like

Here is the reply:

pi@RPI3D:~ $ ls -l ~/OctoPrint/venv/bin/
total 2960
-rw-r--r-- 1 pi pi    2082 Jan  3 17:31 activate
-rw-r--r-- 1 pi pi    1024 Jan  3 17:31 activate.csh
-rw-r--r-- 1 pi pi    2178 Jan  3 17:31
-rw-r--r-- 1 pi pi    1137 Jan  3 17:31
-rwxr-xr-x 1 pi pi     252 Jan  3 17:31 easy_install
-rwxr-xr-x 1 pi pi     252 Jan  3 17:31 easy_install-2.7
-rwxr-xr-x 1 pi pi     239 Jan  3 17:31 pip
-rwxr-xr-x 1 pi pi     239 Jan  3 17:31 pip2
-rwxr-xr-x 1 pi pi     239 Jan  3 17:31 pip2.7
lrwxrwxrwx 1 pi pi       7 Jan  3 17:31 python -> python2
-rwxr-xr-x 1 pi pi 2984816 Jan  3 17:31 python2
lrwxrwxrwx 1 pi pi       7 Jan  3 17:31 python2.7 -> python2
-rwxr-xr-x 1 pi pi    2341 Jan  3 17:31 python-config
-rwxr-xr-x 1 pi pi     230 Jan  3 17:31 wheel
pi@RPI3D:~ $ 

Very weird that there is no file named octoprint, but i still can start octoprint like this:

pi@RPI3D:~ $ cd ~/OctoPrint/venv/bin
pi@RPI3D:~/OctoPrint/venv/bin $ octoprint
Starting the server via "octoprint" is deprecated, please use "octoprint serve" from now on.
2020-01-04 18:35:22,860 - octoprint.startup - INFO - ******************************************************************************
2020-01-04 18:35:22,862 - octoprint.startup - INFO - Starting OctoPrint 1.3.12
2020-01-04 18:35:22,862 - octoprint.startup - INFO - ******************************************************************************

When i do octoprint serve it starts also:

pi@RPI3D:~/OctoPrint/venv/bin $ octoprint serve
2020-01-04 18:36:29,318 - octoprint.startup - INFO - ******************************************************************************
2020-01-04 18:36:29,319 - octoprint.startup - INFO - Starting OctoPrint 1.3.12
2020-01-04 18:36:29,320 - octoprint.startup - INFO - ******************************************************************************

Wait a minute.

Why not use octopi distro? It's muuuuch easier. I just realized you aren't doing that.

Well, i have 4 raspberry pi's running in my house as home automation, and they all run codesys software on raspbian. So that why i wanted raspbian, because i dont know anything about octopi. If an application run on raspbian, wil it also work on octopi?

Yeah, roughly speaking, they're the same thing. It's just a lot more user-friendly because you won't get stuck in these types of oddities.

Okay will try optopi today.

One more thing you can try:
which octoprint
this tells you which binary it runs. It sounds like you installed it in another directory and that directory is in the global path. If you give an absolute path (/path/to/binary) it'll only run exactly this one.

When you switched the path you're not running the octoprint from the local path at all - you would need to run it with ./octoprint serve (the ./ marking that you want to run the binary in the current path.

I support @tedder42 s recommendation of running octopi - it's a raspbian with all the dirty work already done. Although I have to admit I don't own a Pi4 and can't say how it works there ...


1 Like

just installed octopi in another sd card, works perfectly. Later this week i will try to install the software for my home automation and see if that works as well.

@bahmrockk, I will try your suggestion.

For as far as i can see at this point, octopi/octoprint works without any problems on pi4.

There is like 10 results in Google with people having the same problem like this. All of them end with no resolution or someone saying: just install OctoPi.
I will present here what worked for me.

  1. First, run this: (as suggested [here])(Setting up OctoPrint on a Raspberry Pi running Raspbian)
wget && sudo mv octoprint.init /etc/init.d/octoprint
wget && sudo mv octoprint.default /etc/default/octoprint
sudo chmod +x /etc/init.d/octoprint
  1. Then I uncommented, not just DEAMON line, but all of the lines with parameters in /etc/default/octoprint. I am not sure if that was necessary. Since my installation was not done in venv, the config file looks like this:
# Configuration for /etc/init.d/octoprint

# The init.d script will only run if this variable non-empty.

# base directory to use

# configuration file to use

# On what port to run daemon, default is 5000

# Path to the OctoPrint executable, you need to set this to match your installation!

# What arguments to pass to octoprint, usually no need to touch this

# Umask of files octoprint generates, Change this to 000 if running octoprint as its own, separate user

# Process priority, 0 here will result in a priority 20 process.
# -2 ensures Octoprint has a slight priority over user processes.

# Should we run at startup?

Don't put special port 80 like I first did, if you are not done with autostart troubleshooting.

3.You can check if octoprint is called correctly by executing /etc/init.d/octoprint.
If it works, you run:
sudo update-rc.d octoprint defaults
which registers service at the startup. Apparently this is correct way to register a service because, on shutdown, the system will nicely close it down. (You shouldn't use manual editing of etc/rc.local which is an alternative way of starting a daemon, because I think the service will not be managed by systemctl)

  1. Now you can see if it worked by running sudo service octoprint start. My understanding is that if this worked now, it will work on startup. (To simulate startup, I think you can also run sudo systemctl daemon-reload.) In both cases, there was no output shown. You can check if there were any logs in by running tail /var/log/daemon.log. For me this didn't have anything new. But the following command sudo service octoprint status was showing the service has started:
service octoprint status
● octoprint.service - LSB: OctoPrint daemon
   Loaded: loaded (/etc/init.d/octoprint; generated)
   Active: active (running) since Sat 2020-04-25 15:41:31 EDT; 2s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 17061 ExecStart=/etc/init.d/octoprint start (code=exited, status=0/SUCCESS)
   Memory: 7.1M
   CGroup: /system.slice/octoprint.service
           └─17071 /usr/bin/python /home/pi/.local/bin/octoprint serve --config /home/pi/.octoprint/config.yaml --basedir /home/pi/.octoprint --port=5000

That's great. Now don't stop it too soon, because next time octoprint will go to safe mode. If the service has a status exited or you suspect some other problem, look into octoprint logs in tail /home/pi/.octoprint/logs/octoprint.log -n20.

  1. Now reboot or 'sudo systemctl reboot' (btw that is a command to type into your octoprint->server->restart settings in the web gui.). The server should start after few minutes.

That's exactly what I needed. I final got it working. I am going to try and create an octoprint.service file in /etc/systemd/system/ , thus abandoning init.d and relying entirely on systemd

not today however.. lol

edit.... I succeeded in doing just that.

I removed both etc/default/octoprint AND etc/init.d/octoprint.

I created /etc/systemd/system/octoprint.service.

Description=Octoprint Server
ExecStart=/home/pi/OctoPrint/bin/octoprint serve --port=5000

I did a preemptive chmod 777 on octoprint.service

I tested it by the command "sudo systemctl start octoprint" and verified with "service octoprint status"

finally I set it as boot item with "sudo systemctl enable octoprint"

and rebooted. works like a champ.