I am trying to start Geoserver as a systemd service using this script:

(using ubuntu 16.04)




And I get this error in syslog

systemd[1]: Starting Geoserver...    
startup.sh[21823]: The GEOSERVER_HOME environment variable is not defined
    systemd[1]: geoserver.service: Main process exited, code=exited, status=1/FAILURE
    startup.sh[21823]: This environment variable is needed to run this program
    startup.sh[21823]: Please set it to the directory where geoserver was installed
    VM2 systemd[1]: geoserver.service: Failed with result 'exit-code'.
    VM2 systemd[1]: Failed to start Geoserver.

I tried to enter GEOSERVER_HOME in /etc/environment but I still get the same error.

What am I doing wrong?


You can add an environment file to your service definition:


Then create that file (the actual path is up to you) and define your variable there and reload your service definitions:

sudo systemctl daemon-reload

Now the environment variables should be used by your service.

  • Thanks, could this file be /etc/environment which exists already?
    – xpanta
    Dec 5 '19 at 14:46
  • 1
    I don't see why not. This will however define the variable for every user on the system. This is usually not what people want. Dec 5 '19 at 14:47
  • OK, I created the environment file in /home/ermis/geoserver/env with the GEOSERVER_HOME var and added this line in the geoserver.service file: EnvironmentFile=/home/ermis/geoserver/env under Service section. I still get the same error
    – xpanta
    Dec 5 '19 at 14:55
  • I rebooted the server. It works. Thanks
    – xpanta
    Dec 5 '19 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.