Your admin backend is unreachable issue

Hi Forest !

Actual behavior

After switching all my data to a new server, I changed the redirection IP of forest.xxxx.com subdomain , the IP in the file app.js and open the port in the new server but still have this issue.

“Your admin backend is unreachable. Please check that it is running and respond to https://forest.xxxxxx.com.”

When I tried to access forest.xxx.com I have a 502 Bad Gateway error - nginx

Any clue on where to look to fix this ?

Thanks !

Hi @Jonathan,

Welcome to Forest!

The 502 Bad Gateway error as indicated here means that nginx don’t find the upstream server.
Your forest server should be down or the nginx configuration can be wrong.

Regards

Thanks for your answer.

For my sysadmin Forest isn’t start is it possible ?

How can i change configuration of nginx ?

Hi @Jonathan,

Sure, it is possible that your Forest API is down.
This is a component hosted on your servers to connect to your database:

Thanks for your answer.

This is what I see :

Hi @Jonathan,

Your pm2 output explains why you are getting a 502. Since your server is not started, nginx cannot find the upstream server associated to your reverse proxy configuration.

Since your server does not start, you should have log explaining why. Could you share theses logs here?

Thanks in advance

Hi @jeffladiray ,

Thanks for your answer and your help !

You can find the logs here :

0|www    | Model creation error: ReferenceError: models is not defined
0|www    | Error: demande_location.class HasOne extends Association {
0|www    |   constructor(source, target, options) {
0|www    |     super(source, target, options);
0|www    |     this.associationType = 'HasOne';
0|www    |     this.isSingleAssociation = true;
0|www    |     this.foreignKeyAttribute = {};
0|www    |     if (this.as) {
0|www    |       this.isAliased = true;
0|www    |       this.options.name = {
0|www    |         singular: this.as
0|www    |       };
0|www    |     } else {
0|www    |       this.as = this.target.options.name.singular;
0|www    |       this.options.name = this.target.options.name;
0|www    |     }
0|www    |     if (_.isObject(this.options.foreignKey)) {
0|www    |       this.foreignKeyAttribute = this.options.foreignKey;
0|www    |       this.foreignKey = this.foreignKeyAttribute.name || this.foreignKeyAttribute.fieldName;
0|www    |     } else if (this.options.foreignKey) {
0|www    |       this.foreignKey = this.options.foreignKey;
0|www    |     }
0|www    |     if (!this.foreignKey) {
0|www    |       this.foreignKey = Utils.camelizeIf(
0|www    |         [
0|www    |           Utils.underscoredIf(Utils.singularize(this.options.as || this.source.name), this.target.options.underscored),
0|www    |           this.source.primaryKeyAttribute
0|www    |         ].join('_'),
0|www    |         !this.source.options.underscored
0|www    |       );
0|www    |     }
0|www    |     this.sourceIdentifier = this.source.primaryKeyAttribute;
0|www    |     this.sourceKey = this.source.primaryKeyAttribute;
0|www    |     this.sourceKeyIsPrimary = this.sourceKey === this.source.primaryKeyAttribute;
0|www    |     this.associationAccessor = this.as;
0|www    |     this.options.useHooks = options.useHooks;
0|www    |     if (this.target.rawAttributes[this.foreignKey]) {
0|www    |       this.identifierField = this.target.rawAttributes[this.foreignKey].field || this.foreignKey;
0|www    |     }
0|www    |     // Get singular name, trying to uppercase the first letter, unless the model forbids it
0|www    |     const singular = Utils.uppercaseFirst(this.options.name.singular);
0|www    |     this.accessors = {
0|www    |       get: 'get' + singular,
0|www    |       set: 'set' + singular,
0|www    |       create: 'create' + singular
0|www    |     };
0|www    |   }
0|www    |   // the id is in the target table
0|www    |   injectAttributes() {
0|www    |     const newAttributes = {};
0|www    |     const keyType = this.source.rawAttributes[this.source.primaryKeyAttribute].type;
0|www    |     newAttributes[this.foreignKey] = _.defaults({}, this.foreignKeyAttribute, {
0|www    |       type: this.options.keyType || keyType,
0|www    |       allowNull : true
0|www    |     });
0|www    |     Utils.mergeDefaults(this.target.rawAttributes, newAttributes);
0|www    |     this.identifierField = this.target.rawAttributes[this.foreignKey].field || this.foreignKey;
0|www    |     if (this.options.constraints !== false) {
0|www    |       const target = this.target.rawAttributes[this.foreignKey] || newAttributes[this.foreignKey];
0|www    |       this.options.onDelete = this.options.onDelete || (target.allowNull ? 'SET NULL' : 'CASCADE');
0|www    |       this.options.onUpdate = this.options.onUpdate || 'CASCADE';
0|www    |     }
0|www    |     Helpers.addForeignKeyConstraints(this.target.rawAttributes[this.foreignKey], this.source, this.target, this.options);
0|www    |     // Sync attributes and setters/getters to Model prototype
0|www    |     this.target.refreshAttributes();
0|www    |     Helpers.checkNamingCollision(this);
0|www    |     return this;
0|www    |   }
0|www    |   mixin(obj) {
0|www    |     const methods = ['get', 'set', 'create'];
0|www    |     Helpers.mixinMethods(this, obj, methods);
0|www    |   }
0|www    |   /**
0|www    |    * Get the associated instance.
0|www    |    *
0|www    |    * @param {Object} [options]
0|www    |    * @param {String|Boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false
0|www    |    * @param {String} [options.schema] Apply a schema on the related model
0|www    |    * @see {@link Model.findOne} for a full explanation of options
0|www    |    * @return {Promise<Model>}
0|www    |    */
0|www    |   get(instances, options) {
0|www    |     const association = this;
0|www    |     const where = {};
0|www    |     let Target = association.target;
0|www    |     let instance;
0|www    |     options = Utils.cloneDeep(options);
0|www    |     if (options.hasOwnProperty('scope')) {
0|www    |       if (!options.scope) {
0|www    |         Target = Target.unscoped();
0|www    |       } else {
0|www    |         Target = Target.scope(options.scope);
0|www    |       }
0|www    |     }
0|www    |     if (options.hasOwnProperty('schema')) {
0|www    |       Target = Target.schema(options.schema, options.schemaDelimiter);
0|www    |     }
0|www    |     if (!Array.isArray(instances)) {
0|www    |       instance = instances;
0|www    |       instances = undefined;
0|www    |     }
0|www    |     if (instances) {
0|www    |       where[association.foreignKey] = {
0|www    |         $in: instances.map(instance => instance.get(association.sourceKey))
0|www    |       };
0|www    |     } else {
0|www    |       where[association.foreignKey] = instance.get(association.sourceKey);
0|www    |     }
0|www    |     if (association.scope) {
0|www    |       _.assign(where, association.scope);
0|www    |     }
0|www    |     options.where = options.where ?
0|www    |       {$and: [where, options.where]} :
0|www    |       where;
0|www    |     if (instances) {
0|www    |       return Target.findAll(options).then(results => {
0|www    |         const result = {};
0|www    |         for (const instance of instances) {
0|www    |           result[instance.get(association.sourceKey, {raw: true})] = null;
0|www    |         }
0|www    |         for (const instance of results) {
0|www    |           result[instance.get(association.foreignKey, {raw: true})] = instance;
0|www    |         }
0|www    |         return result;
0|www    |       });
0|www    |     }
0|www    |     return Target.findOne(options);
0|www    |   }
0|www    |   /**
0|www    |    * Set the associated model.
0|www    |    *
0|www    |    * @param {Model|String|Number} [newAssociation] An persisted instance or the primary key of a persisted instance to associate with this. Pass `null` or `undefined` to remove the association.
0|www    |    * @param {Object} [options] Options passed to getAssociation and `target.save`
0|www    |    * @return {Promise}
0|www    |    */
0|www    |   set(sourceInstance, associatedInstance, options) {
0|www    |     const association = this;
0|www    |     let alreadyAssociated;
0|www    |     options = _.assign({}, options, {
0|www    |       scope: false
0|www    |     });
0|www    |     return sourceInstance[association.accessors.get](options).then(oldInstance => {
0|www    |       // TODO Use equals method once #5605 is resolved
0|www    |       alreadyAssociated = oldInstance && associatedInstance && _.every(association.target.primaryKeyAttributes, attribute =>
0|www    |         oldInstance.get(attribute, {raw: true}) === (associatedInstance.get ? associatedInstance.get(attribute, {raw: true}) : associatedInstance)
0|www    |       );
0|www    |       if (oldInstance && !alreadyAssociated) {
0|www    |         oldInstance[association.foreignKey] = null;
0|www    |         return oldInstance.save(_.extend({}, options, {
0|www    |           fields: [association.foreignKey],
0|www    |           allowNull: [association.foreignKey],
0|www    |           association: true
0|www    |         }));
0|www    |       }
0|www    |     }).then(() => {
0|www    |       if (associatedInstance && !alreadyAssociated) {
0|www    |         if (!(associatedInstance instanceof association.target)) {
0|www    |           const tmpInstance = {};
0|www    |           tmpInstance[association.target.primaryKeyAttribute] = associatedInstance;
0|www    |           associatedInstance = association.target.build(tmpInstance, {
0|www    |             isNewRecord: false
0|www    |           });
0|www    |         }
0|www    |         _.assign(associatedInstance, association.scope);
0|www    |         associatedInstance.set(association.foreignKey, sourceInstance.get(association.sourceIdentifier));
0|www    |         return associatedInstance.save(options);
0|www    |       }
0|www    |       return null;
0|www    |     });
0|www    |   }
0|www    |   /**
0|www    |    * Create a new instance of the associated model and associate it with this.
0|www    |    *
0|www    |    * @param {Object} [values]
0|www    |    * @param {Object} [options] Options passed to `target.create` and setAssociation.
0|www    |    * @see {@link Model#create} for a full explanation of options
0|www    |    * @return {Promise}
0|www    |    */
0|www    |   create(sourceInstance, values, options) {
0|www    |     const association = this;
0|www    |     values = values || {};
0|www    |     options = options || {};
0|www    |     if (association.scope) {
0|www    |       for (const attribute of Object.keys(association.scope)) {
0|www    |         values[attribute] = association.scope[attribute];
0|www    |         if (options.fields) {
0|www    |           options.fields.push(attribute);
0|www    |         }
0|www    |       }
0|www    |     }
0|www    |     values[association.foreignKey] = sourceInstance.get(association.sourceIdentifier);
0|www    |     if (options.fields) {
0|www    |       options.fields.push(association.foreignKey);
0|www    |     }
0|www    |     return association.target.create(values, options);
0|www    |   }
0|www    | } called with something that's not a subclass of Sequelize.Model
0|www    |     at Function.<anonymous> (/data/vhosts/COMPANY-NAME/forestadmin-test/node_modules/sequelize/lib/associations/mixin.js:81:13)
0|www    |     at Function.DemandeLocation.associate (/data/vhosts/COMPANY-NAME/forestadmin-test/models/demande_location.js:127:21)
0|www    |     at /data/vhosts/COMPANY-NAME/forestadmin-test/models/index.js:43:19
0|www    |     at Array.forEach (<anonymous>)
0|www    |     at Object.<anonymous> (/data/vhosts/COMPANY-NAME/forestadmin-test/models/index.js:41:17)
0|www    |     at Module._compile (internal/modules/cjs/loader.js:999:30)
0|www    |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
0|www    |     at Module.load (internal/modules/cjs/loader.js:863:32)
0|www    |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
0|www    |     at Module.require (internal/modules/cjs/loader.js:887:19)
0|www    |     at Module.Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:70:39)
0|www    |     at require (internal/modules/cjs/helpers.js:74:18)
0|www    |     at Object.<anonymous> (/data/vhosts/COMPANY-NAME/forestadmin-test/routes/demande_location.js:5:16)
0|www    |     at Module._compile (internal/modules/cjs/loader.js:999:30)
0|www    |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
0|www    |     at Module.load (internal/modules/cjs/loader.js:863:32)
0|www    |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
0|www    |     at Module.require (internal/modules/cjs/loader.js:887:19)
0|www    |     at Module.Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:70:39)
0|www    |     at require (internal/modules/cjs/helpers.js:74:18)
0|www    |     at /data/vhosts/COMPANY-NAME/forestadmin-test/app.js:36:24
0|www    |     at Array.forEach (<anonymous>)
0|www    |     at Object.<anonymous> (/data/vhosts/COMPANY-NAME/forestadmin-test/app.js:34:28)
0|www    |     at Module._compile (internal/modules/cjs/loader.js:999:30)
0|www    |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
0|www    |     at Module.load (internal/modules/cjs/loader.js:863:32)
0|www    |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
0|www    |     at Module.require (internal/modules/cjs/loader.js:887:19)
0|www    |     at Module.Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:70:39)
0|www    |     at require (internal/modules/cjs/helpers.js:74:18)
0|www    |     at Object.<anonymous> (/data/vhosts/COMPANY-NAME/forestadmin-test/bin/www:3:13)
0|www    |     at Module._compile (internal/modules/cjs/loader.js:999:30)
0|www    |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
0|www    |     at Module.load (internal/modules/cjs/loader.js:863:32)
PM2      | App [www:0] exited with code [1] via signal [SIGINT]
PM2      | App [www:0] starting in -fork mode-
PM2      | App [www:0] online

Hey @Jonathan,

Could you share your project name so I can check on my end if I can spot anything?
Did you recently do the migration to our new version 7 of forest-express-sequelize ?

Thanks :pray:

I just sent you a PM.

For information we didn’t did any migration of Forest.

1 Like

0|www | Model creation error: ReferenceError: models is not defined
refers to a file containing a reference to the models variable that is not imported.

The stacktrace I asked you refers to multiples files that can contain this issue. Does this appear for all you forestadmin environment or in production only?
You should easily be able to spot this issue on your development environment since the server does not start at all.