# \[solved\] Restoring config.json fails

**URL:** <https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415>\
**Category:** Troubleshooting\
**Created:** [December 26, 2018, 7:42am UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415 "2018-12-26T07:42:24Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![arnuschky](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@arnuschky](https://forum.mattermost.com/u/arnuschky)\
**Post date:** [December 26, 2018, 7:42am UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415/1 "2018-12-26T07:42:24Z")

</div>

#### Summary

Restoring config.json after migrating to another server fails  
Issue in one concise sentence

#### Steps to reproduce

1. Backup MM following [https://docs.mattermost.com/administration/backup.html](https://docs.mattermost.com/administration/backup.html)
2. Restore MM
  - restore DB dump
  - copy data dir
  - copy config.json

#### Expected behavior

MM starts

#### Observed behavior

When copying config.json MM fails to start with a very unspecific error (/var/log/gitlab/mattermost/mattermost.log):

```
{"level":"info","ts":1545783114.786322,"caller":"utils/config.go:211","msg":"Config file watcher detected a change reloading /var/opt/gitlab/mattermost/config.json"}
{"level":"error","ts":1545783114.7864351,"caller":"utils/config.go:216","msg":"Failed to read while watching config file at /var/opt/gitlab/mattermost/config.json with err=parsing error at line 1, character 1: unexpected end of JSON input"}
{"level":"info","ts":1545783114.8663583,"caller":"utils/config.go:211","msg":"Config file watcher detected a change reloading /var/opt/gitlab/mattermost/config.json"}

```

MM versions on both servers should be the same. (Using gitlab omnibus.)

When I remove config.json, MM starts with all channels and attachments, but the system config is missing obviously. So it seems that there is some incompatibility that prevents me to move my old config to the new server. I can’t figure out what though as the log messages is basically useless.

Did anyone encounter this previously?

Mattermost Version: 5.5.0  
Database Schema Version: 5.5.0  
Database: postgres

---

<div class="post-metadata">

**Author:** ![arnuschky](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@arnuschky](https://forum.mattermost.com/u/arnuschky)\
**Post date:** [December 26, 2018, 7:43am UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415/2 "2018-12-26T07:43:57Z")

</div>

PS: config file is not corrupted, correct JSON, hash of file is same as on old servers  
PPS: servers differ in underlying Ubuntu version (16.04 vs. 18.04)

---

<div class="post-metadata">

**Author:** ![jasonblais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jasonblais/32/720_2.png) [@jasonblais](https://forum.mattermost.com/u/jasonblais)\
**Post date:** [December 31, 2018, 3:58am UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415/3 "2018-12-31T03:58:05Z")

</div>

Good question. I’ve touched base with our team to see if they have insight on this.

Edit: I posted it here in case you’re interested joining our community server 🙂 [https://community.mattermost.com/core/pl/jcdh6s19oj839gs169tbqpjzsw](https://community.mattermost.com/core/pl/jcdh6s19oj839gs169tbqpjzsw)

---

<div class="post-metadata">

**Author:** ![hmhealey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/hmhealey/32/1915_2.png) [@hmhealey](https://forum.mattermost.com/u/hmhealey)\
**Post date:** [January 2, 2019, 2:40pm UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415/4 "2019-01-02T14:40:20Z")

</div>

Hi @arnuschky,

That’s interesting. I’m not aware of any reason that a config should work on one server but not the other.

It looks like you’re copying the new config over while the MM server is still running. Is that the case? If so, there might be some issue with the server trying to read the file as it’s still being populated, so you could try stopping the server with `gitlab-ctl stop mattermost`, replacing the config, and then restarting it with `gitlab-ctl start mattermost`.

---

<div class="post-metadata">

**Author:** ![arnuschky](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@arnuschky](https://forum.mattermost.com/u/arnuschky)\
**Post date:** [January 5, 2019, 7:08pm UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415/5 "2019-01-05T19:08:47Z")

</div>

No, that’s what I first suspected but wasn’t the cause in the end.

I guess I have to go over the config line-by-line and see what section is the issue. Is there anything that’s OS dependent in there?

---

<div class="post-metadata">

**Author:** ![jesse](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jesse/32/5168_2.png) [@jesse](https://forum.mattermost.com/u/jesse)\
**Post date:** [January 9, 2019, 7:59pm UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415/6 "2019-01-09T19:59:45Z")

</div>

> [@arnuschky](#):
>
> When I remove config.json, MM starts with all channels and attachments, but the system config is missing obviously.

@arnuschky, can you clarify this point? How is your server successfully starting up (and connecting to the database) if the `config.json` is removed altogether? May I assume some kind of environment variables at play?

---

<div class="post-metadata">

**Author:** ![arnuschky](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@arnuschky](https://forum.mattermost.com/u/arnuschky)\
**Post date:** [January 9, 2019, 8:27pm UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415/7 "2019-01-09T20:27:39Z")

</div>

Sorry that was nonsense. What I did (I think) was: I removed config.json and then did a gitlab-reconfigure, which re-writes config.json with the correct base values (like db connection etc). I suspect gitlab does this only on the first install and doesn’t touch the config file afterwards. Or maybe it sets some env vars, I am not 100% how MM is integrated into gitlab.

What remains is that copying a config file from the same MM version, same gitlab version, from another install, doesn’t work.

I can test this again if necessary.

---

<div class="post-metadata">

**Author:** ![jesse](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jesse/32/5168_2.png) [@jesse](https://forum.mattermost.com/u/jesse)\
**Post date:** [January 9, 2019, 9:22pm UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415/8 "2019-01-09T21:22:22Z")

</div>

Got it: it might be useful to diff the copied config file with the auto-generated one.

There shouldn’t be anything OS dependent in the configuration file. The error you’re seeing is supposed to signal that the file is not valid JSON and that the error occurred at the start of the file (or perhaps that the file was completely empty).

---

<div class="post-metadata">

**Author:** ![arnuschky](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@arnuschky](https://forum.mattermost.com/u/arnuschky)\
**Post date:** [January 9, 2019, 11:46pm UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415/9 "2019-01-09T23:46:00Z")

</div>

It wasn’t, I checked that. It looked completely sane. I also ran it through a JSON linter; it passed without errors. So the error MM is showing is either bogus or it fails to read the file for some unknown reason.

---

<div class="post-metadata">

**Author:** ![hmhealey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/hmhealey/32/1915_2.png) [@hmhealey](https://forum.mattermost.com/u/hmhealey)\
**Post date:** [January 10, 2019, 4:16pm UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415/10 "2019-01-10T16:16:32Z")

</div>

What if you use the config.json generated by Mattermost and then paste contents of the old file into the new one instead of replacing the file entirely? It may be a permissions error even though I don’t know it would produce that specific error message.

---

<div class="post-metadata">

**Author:** ![arnuschky](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@arnuschky](https://forum.mattermost.com/u/arnuschky)\
**Post date:** [January 15, 2019, 11:21am UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415/11 "2019-01-15T11:21:23Z")

</div>

I was unable to reproduce the problem when testing again. I suspect that the whole report was bogus, for example caused by myself doing the migration while being dead tired. Sorry about that.

In any case, the problem is resolved, I managed to restore my original config.json without any issue.

Thank you all for your help.

---

<div class="post-metadata">

**Author:** ![hmhealey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/hmhealey/32/1915_2.png) [@hmhealey](https://forum.mattermost.com/u/hmhealey)\
**Post date:** [January 15, 2019, 2:03pm UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415/12 "2019-01-15T14:03:23Z")

</div>

No worries. Just glad to hear the problem is fixed. 🙂

---

<div class="post-metadata">

**Author:** ![arnuschky](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@arnuschky](https://forum.mattermost.com/u/arnuschky)\
**Post date:** [May 6, 2019, 9:47am UTC](https://forum.mattermost.com/t/solved-restoring-config-json-fails/6415/13 "2019-05-06T09:47:09Z")

</div>

Faced this problem again. Traced it back to a bug that the server fails to start after enabling email notifications. For further details see: [Enabling email notifications caues mattermost not to start](https://forum.mattermost.com/t/enabling-email-notifications-caues-mattermost-not-to-start/1717/6)
