[solved] 502 Bad Gateway since version 2.9

Infos:

  • Used Zammad version: 2.9
  • Used Zammad installation source: package
  • Operating system: Ubuntu 18.04.2
  • Browser + version: Chrome 72.0.3626.109 (Official Build) (64-bit) (cohort: Stable) Revision fae8db7ab9280fa6704a59980263c804f809ebd5-refs/branch-heads/3626@{#857}

Expected behavior:

  • Installation wizard

Actual behavior:

  • 502 Bad Gateway

Steps:

  • Install Elasticsearch and it attachment plugin
  • Install Zammad on Ubuntu via DEB
  • Modify server_name in zammad.conf
  • Restart nginx

Hardware:

DigitalOcean Droplet

  • 2 vCPUs
  • 4 GB
  • 80 GB Disk

Logs:

zammad.error.log

2019/02/19 15:58:03 [error] 1751#1751: *13 connect() failed (111: Connection refused) while connecting to upstream, client: (redacted), server: (redacted), request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "(redacted)"
2019/02/19 16:07:57 [error] 1751#1751: *16 connect() failed (111: Connection refused) while connecting to upstream, client: (redacted), server: (redacted), request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "(redacted)"
2019/02/19 16:15:17 [error] 1751#1751: *23 connect() failed (111: Connection refused) while connecting to upstream, client: (redacted), server: (redacted), request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "(redacted)"
2019/02/19 16:34:45 [error] 32223#32223: *1 connect() failed (111: Connection refused) while connecting to upstream, client: (redacted), server: (redacted), request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "(redacted)"

zammad.conf

#
# this is the nginx config for zammad
#

upstream zammad-railsserver {
    server 127.0.0.1:3000;
}

upstream zammad-websocket {
    server 127.0.0.1:6042;
}

server {
    listen 80;

    # replace 'localhost' with your fqdn if you want to use zammad from remote
    server_name (redacted);

    root /opt/zammad/public;

    access_log /var/log/nginx/zammad.access.log;
    error_log  /var/log/nginx/zammad.error.log;

    client_max_body_size 50M;

    location ~ ^/(assets/|robots.txt|humans.txt|favicon.ico) {
        expires max;
    }

    location /ws {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header CLIENT_IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 86400;
        proxy_pass http://zammad-websocket;
    }

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header CLIENT_IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 300;
        proxy_pass http://zammad-railsserver;

        gzip on;
        gzip_types text/plain text/xml text/css image/svg+xml application/javascript application/x-javascript application/json application/xml;
        gzip_proxied any;
    }
}

systemctl status zammad

- zammad.service
   Loaded: loaded (/etc/systemd/system/zammad.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-02-19 14:20:20 UTC; 1h 53min ago
 Main PID: 16740 (sleep)
    Tasks: 1 (limit: 4704)
   CGroup: /system.slice/zammad.service
           └─16740 /bin/sleep infinity

Feb 19 14:20:20 (redacted) systemd[1]: Started zammad.service.

systemctl status zammad-web

- zammad-web.service
   Loaded: loaded (/etc/systemd/system/zammad-web.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-02-19 16:32:30 UTC; 36s ago
 Main PID: 1246 (sleep)
    Tasks: 1 (limit: 4704)
   CGroup: /system.slice/zammad-web.service
           └─1246 /bin/sleep infinity

Feb 19 16:32:30 (redacted) systemd[1]: Started zammad-web.service.

systemctl status zammad-worker

- zammad-worker.service
   Loaded: loaded (/etc/systemd/system/zammad-worker.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-02-19 14:20:20 UTC; 2h 0min ago
 Main PID: 16748 (sleep)
    Tasks: 1 (limit: 4704)
   CGroup: /system.slice/zammad-worker.service
           └─16748 /bin/sleep infinity

Feb 19 14:20:20 (redacted) systemd[1]: Started zammad-worker.service.

systemctl status zammad-websocket

- zammad-websocket.service
   Loaded: loaded (/etc/systemd/system/zammad-websocket.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-02-19 14:20:20 UTC; 1h 56min ago
 Main PID: 16747 (sleep)
    Tasks: 1 (limit: 4704)
   CGroup: /system.slice/zammad-websocket.service
           └─16747 /bin/sleep infinity

Feb 19 14:20:20 (redacted) systemd[1]: Started zammad-websocket.service.

This is a new installed instance?
Check if you have a firewall that’s blocking your requests, as 111: Connection refused) in your logfiles is a good indicator for that. Also ensure that this is the only zammad config being used.

Edit: Production log is giving nothing, I suppose?

Hello and thank you so much for taking your time to reply.

This is a new installed instance?

Apologies. Yes, this is a new instance indeed.

Check if you have a firewall that’s blocking your requests, as 111: Connection refused) in your logfiles is a good indicator for that.

As far as I can tell, firewall should be turned off as ufw status returns inactive. Please correct me if I’m wrong.

Also ensure that this is the only zammad config being used.

How can I do so? Currently, zammad.conf is the one and only file in the sites-available directory, if that’s what you mean.

Edit: Production log is giving nothing, I suppose?

Correct. As it stands, /var/log/zammad/production.log does not exist.

I’m not sure, but the ruby server doesn’t seem to be running.

~# curl 127.0.0.1:3000
curl: (7) Failed to connect to 127.0.0.1 port 3000: Connection refused
~# curl localhost:3000
curl: (7) Failed to connect to localhost port 3000: Connection refused
~# curl (local ip):3000
curl: (7) Failed to connect to (local ip) port 3000: Connection refused
~# curl (ip):3000
curl: (7) Failed to connect to (ip) port 3000: Connection refused

So, zammad run rails c:

The Imlib2 library could not be loaded. You can install it using

yum install imlib2 imlib2-devel
apt-get install libimlib2 libimlib2-dev

/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:85:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'rszr'. (Bundler::GemRequireError)
Gem Load Error is: can't load libImlib2.so
Backtrace for gem load error is:
/opt/zammad/vendor/ruby-2.4.4/lib/ruby/2.4.0/fiddle/import.rb:89:in `rescue in block in dlload'
/opt/zammad/vendor/ruby-2.4.4/lib/ruby/2.4.0/fiddle/import.rb:86:in `block in dlload'
/opt/zammad/vendor/ruby-2.4.4/lib/ruby/2.4.0/fiddle/import.rb:77:in `collect'
/opt/zammad/vendor/ruby-2.4.4/lib/ruby/2.4.0/fiddle/import.rb:77:in `dlload'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/rszr-0.3.2/lib/rszr/lib.rb:14:in `<module:Lib>'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/rszr-0.3.2/lib/rszr/lib.rb:3:in `<module:Rszr>'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/rszr-0.3.2/lib/rszr/lib.rb:1:in `<top (required)>'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `block in require'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:258:in `load_dependency'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/rszr-0.3.2/lib/rszr.rb:8:in `<top (required)>'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:82:in `require'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:82:in `block (2 levels) in require'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `each'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `block in require'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `each'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `require'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler.rb:108:in `require'
/opt/zammad/config/application.rb:10:in `<top (required)>'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6.1/lib/rails/command/actions.rb:15:in `require'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6.1/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6.1/lib/rails/commands/console/console_command.rb:96:in `perform'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6.1/lib/rails/command/base.rb:63:in `perform'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6.1/lib/rails/command.rb:44:in `invoke'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6.1/lib/rails/commands.rb:16:in `<top (required)>'
/opt/zammad/bin/rails:9:in `require'
/opt/zammad/bin/rails:9:in `<main>'
Bundler Error Backtrace:
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `each'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `block in require'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `each'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `require'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler.rb:108:in `require'
    from /opt/zammad/config/application.rb:10:in `<top (required)>'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6.1/lib/rails/command/actions.rb:15:in `require'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6.1/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6.1/lib/rails/commands/console/console_command.rb:96:in `perform'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6.1/lib/rails/command/base.rb:63:in `perform'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6.1/lib/rails/command.rb:44:in `invoke'
    from /opt/zammad/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6.1/lib/rails/commands.rb:16:in `<top (required)>'
    from /opt/zammad/bin/rails:9:in `require'
    from /opt/zammad/bin/rails:9:in `<main>'

After installing libimlib2 libimlib2-dev, Zammad returns a 500 error page.

/var/log/zammad/production.log

I, [2019-02-19T18:25:50.677326 #21754-47427155773820]  INFO -- : Started GET "/" for (redacted) at 2019-02-19 18:25:50 +0000
F, [2019-02-19T18:25:50.689449 #21754-47427155773820] FATAL -- :
F, [2019-02-19T18:25:50.689531 #21754-47427155773820] FATAL -- : ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR:  relation "settings" does not exist
LINE 8:                WHERE a.attrelid = '"settings"'::regclass
                                          ^
:               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
                     c.collname, col_description(a.attrelid, a.attnum) AS comment
                FROM pg_attribute a
                LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
                LEFT JOIN pg_type t ON a.atttypid = t.oid
                LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
               WHERE a.attrelid = '"settings"'::regclass
                 AND a.attnum > 0 AND NOT a.attisdropped
               ORDER BY a.attnum
):
F, [2019-02-19T18:25:50.690174 #21754-47427155773820] FATAL -- :
F, [2019-02-19T18:25:50.690231 #21754-47427155773820] FATAL -- : app/models/setting.rb:104:in `load'
app/models/setting.rb:55:in `get'
I, [2019-02-19T18:25:51.683747 #21754-47427155772220]  INFO -- : Started GET "/" for (redacted) at 2019-02-19 18:25:51 +0000
F, [2019-02-19T18:25:51.685511 #21754-47427155772220] FATAL -- :
F, [2019-02-19T18:25:51.685585 #21754-47427155772220] FATAL -- : ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR:  relation "settings" does not exist
LINE 8:                WHERE a.attrelid = '"settings"'::regclass
                                          ^
:               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
                     c.collname, col_description(a.attrelid, a.attnum) AS comment
                FROM pg_attribute a
                LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
                LEFT JOIN pg_type t ON a.atttypid = t.oid
                LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
               WHERE a.attrelid = '"settings"'::regclass
                 AND a.attnum > 0 AND NOT a.attisdropped
               ORDER BY a.attnum
):
F, [2019-02-19T18:25:51.685607 #21754-47427155772220] FATAL -- :
F, [2019-02-19T18:25:51.685630 #21754-47427155772220] FATAL -- : app/models/setting.rb:104:in `load'
app/models/setting.rb:55:in `get'

Oh wow, something must have went terribly wrong during your installation.
Did you receive any errors during setup?

Please try to reset your database:

zammad run rake db:drop
zammad run rake db:create
zammad run rake db:migrate
zammad run rake db:seed

This might solve your problems

Once more, I attempted to install Zammad following the documentation. This time, however, I made sure to keep a log to be able to read after everything’s said and done, which I did not do previously (apologies).

As mentioned previously, the same error pops up during installation:

The Imlib2 library could not be loaded.

Here’s the complete installation log: https://privatebin.net/?a97fc2096f23978f#veOjCgfhXAjh+pfAq0lZ29sfyNg0MqSUnBVlgJpKafk=

So, installing the required packages before installing Zammad did it for me:

apt-get install libimlib2 libimlib2-dev

Thank you so much for your time and concern!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.