openHABian: 502 bad gateway after update laste night

Hi everyone,
made an update last night to openHAB 2.3.0~20180501231708-1 (Build #1269) by using the openhabian-config procedure on my RPi3.

Since then, my nginx is not working anymore - no matter if I try to access openhab external or internal, I always get: 502 bad gateway

Any ideas what could have run wrong and how to get the system working again?
I didn’t change anything else, so it has to be the update…


P.S.: Service is running:

[18:28:48] openhabian@openHABianPi:~$ sudo systemctl status openhab2.service -l
● openhab2.service - openHAB 2 - empowering the smart home
   Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2018-05-02 18:28:48 CEST; 17s ago
  Process: 1256 ExecStop=/usr/share/openhab2/runtime/bin/karaf stop (code=exited, status=0/SUCCESS)
 Main PID: 1393 (java)
   CGroup: /system.slice/openhab2.service
           └─1393 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.logdir=/var/log/openhab2

Mai 02 18:28:48 openHABianPi systemd[1]: Started openHAB 2 - empowering the smart home.

Hi @Boby, does a direct (and internal) connection to openHAB’s HTTP server work (not through NGINX), i.e
http://[ip address]:8080

Hi @Benjy, nope - it also says “bad gateway”. I can ping the Raspberry and I can connect through SSH, but currently I lost my web interface. I’m running a reverse proxy - could there be some flaw in the configuration after last nights update?

I’m not fully sure, but somehow I have the feeling, my nginx config got changed completel (/etc/nginx/nginx.conf)…
[Edit]: I found my configuration in the sites-enabled folder; so an altered nginx.conf doesn’t seem to be the problem

That’s odd, nginx shouldn’t be operating on port 8080. Would you be able to post the contents of the config in the site-enabled folder? Be sure to replace your domain with some placeholder.

Just noticed, I’m only operating using SSH - port 80 of my domain is shut down - and also http://[local ip]:8080 doesn’t work. Only https://[local ip]:443 works - whereas “works” means “502 bad gateway”

Here’s my config:

server {
    listen                          80;
    server_name                     [name of my domain];
    return 301                      https://$server_name$request_uri;

server {
    listen                                    443 ssl;
    server_name                               [name of my domain];

    ssl_certificate                           /etc/letsencrypt/live/[name of my domain]/fullchain.pem;
    ssl_certificate_key                       /etc/letsencrypt/live/[name of my domain]/privkey.pem;
    add_header                                Strict-Transport-Security "max-age=31536000";

    location / {
        proxy_pass                            http://localhost:8080/;
        proxy_set_header Host                 $http_host;
        proxy_set_header X-Real-IP            $remote_addr;
        proxy_set_header X-Forwarded-For      $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto    $scheme;

        auth_basic                            "Username & password:";
        auth_basic_user_file                  /etc/nginx/.htpasswd;


    location /.well-known/acme-challenge/ {
        root                                  /var/www/[name of my domain];

    location /doorcam {
        proxy_pass                  ;
        proxy_set_header Host                 $http_host;
        proxy_set_header X-Real-IP            $remote_addr;
        proxy_set_header X-Forwarded-For      $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto    $scheme;



Right, I don’t think this is an issue with nginx at all. Most likely nothing is responding on port 8080 so nginx has nothing to proxy.

What is the output of:

openhab-cli info

also are there any errors in the logs

openhab-cli showlogs

Here it is:

Version:     2.3.0-SNAPSHOT (#1269)

User:        openhab (Active Process 1393)
User Groups: openhab tty dialout audio gpio

Directories: Folder Name      | Path                        | User:Group
             -----------      | ----                        | ----------
             OPENHAB_HOME     | /usr/share/openhab2         | openhab:openhab
             OPENHAB_RUNTIME  | /usr/share/openhab2/runtime | openhab:openhab
             OPENHAB_USERDATA | /var/lib/openhab2           | openhab:openhab
             OPENHAB_CONF     | /etc/openhab2               | openhab:openhab
             OPENHAB_LOGDIR   | /var/log/openhab2           | openhab:openhabian


As I said, I didn’t change anything in the config (for weeks now).
The last thing I can find in the openhab.log is from this morning where I made an update by using openhabian-config:

==> /var/log/openhab2/openhab.log <==
2018-05-02 08:43:18.455 [INFO ] [basic.internal.servlet.WebAppServlet] - Stopped Basic UI
2018-05-02 08:43:28.486 [INFO ] [lgtv.lginteraction.LgTvMessageReader] - Stopped LgTv Servlet
2018-05-02 08:43:28.490 [INFO ] [lgtv.lginteraction.LgTvMessageReader] - Stopped LgTv Servlet
2018-05-02 08:43:28.493 [INFO ] [lgtv.lginteraction.LgTvMessageReader] - Stopped LgTv Servlet
2018-05-02 08:43:28.572 [INFO ] [] - Stopping broker connection 'mqtt_broker'
2018-05-02 08:43:28.689 [INFO ] [io.openhabcloud.internal.CloudClient] - Shutting down openHAB Cloud service connection
2018-05-02 08:43:28.718 [INFO ] [io.openhabcloud.internal.CloudClient] - Disconnected from the openHAB Cloud service (UUID = eeae7573-2944-4e7f-adc5-94543ff9b69d, base URL = http://localhost:8080)
2018-05-02 08:43:28.872 [INFO ] [b.core.service.AbstractActiveService] - Exec Refresh Service has been shut down
2018-05-02 08:43:31.553 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Stopped Paper UI
2018-05-02 08:43:31.601 [INFO ] [.dashboard.internal.DashboardService] - Stopped Dashboard

Before we spend ages looking for a possible update error - is there a quick way to reinstall OH2-binaries (without losing the config)

Many thanks for your support!

Not a problem, your logs finish at saying that it’s stopped the dashboard (which is the web service), and it never restarts. If the process got stuck during the update, it’s best as you say to do a reinstall. first will make sure the process has stopped.

sudo systemctl stop openhab2
openhab-cli info

If the output still says:

openhab (Active Process 1393)

then we need to force kill the process.

kill -9 1393

Finally, reinstall openHAB2, keeping your configuration intact:

sudo apt install --reinstall openhab2

Hi Benjy,
after I reinstalled OH2 following your description, everything works fine again. Thank you so much!

1 Like

Glad to hear it! :slight_smile: I’m guessing it was a very rare occurrence but if you come across the problem again then please let me know, and I’ll see if I can reproduce it.

1 Like

Made again an update today, got a bad gateway again…don’t know what’s wrong, but it’s getting boring :-1: