# 502 Bad Gateway using ubuntu, ansible, lxc, nginx and mattermost

**URL:** <https://forum.mattermost.com/t/502-bad-gateway-using-ubuntu-ansible-lxc-nginx-and-mattermost/7572>\
**Category:** Troubleshooting\
**Created:** [June 28, 2019, 5:59pm UTC](https://forum.mattermost.com/t/502-bad-gateway-using-ubuntu-ansible-lxc-nginx-and-mattermost/7572 "2019-06-28T17:59:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcurt11n](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jcurt11n](https://forum.mattermost.com/u/jcurt11n)\
**Post date:** [June 28, 2019, 5:59pm UTC](https://forum.mattermost.com/t/502-bad-gateway-using-ubuntu-ansible-lxc-nginx-and-mattermost/7572/1 "2019-06-28T17:59:01Z")

</div>

Hello. I have ubuntu desktop 18.04.02 running in virtualbox. I have installed linux containers running on ubuntu and have installed ansible(2.5.1) on the ubuntu desktop. I created 3 linux containers (lxc). on one of the containers i have nginx(version 1.14.2) running as well as mattermost(version 5.12.0). the problem is that when i invoke firefox on the ubuntu desktop and try to access mattermost running on the matterweb linux container, I receive a " 502 Bad Gateway" message.

When I run “systemctl status mattermost” on the matterweb linux container, I get the following  
root@matterweb:/etc/nginx/conf.d# systemctl status mattermost  
● mattermost.service - Mattermost  
Loaded: loaded (/etc/systemd/system/mattermost.service; enabled; vendor preset: enabled)  
Active: failed (Result: exit-code) since Fri 2019-06-28 13:58:23 UTC; 1h 14min ago  
Process: 78 ExecStart=/home/mattermost/mattermost\_app/bin/platform (code=exited, status=102)  
Main PID: 78 (code=exited, status=102)

Jun 28 13:57:51 matterweb platform[78]: {“level”:“info”,“ts”:1561730271.959878,“caller”:“sqlstore/supplier.go:224”,“ms  
Jun 28 13:57:51 matterweb platform[78]: {“level”:“error”,“ts”:1561730271.9624765,“caller”:“sqlstore/supplier.go:236”,”  
Jun 28 13:58:01 matterweb platform[78]: {“level”:“info”,“ts”:1561730281.9636757,“caller”:“sqlstore/supplier.go:224”,"m  
Jun 28 13:58:01 matterweb platform[78]: {“level”:“error”,“ts”:1561730281.966658,“caller”:“sqlstore/supplier.go:236”,"m  
Jun 28 13:58:11 matterweb platform[78]: {“level”:“info”,“ts”:1561730291.9675682,“caller”:“sqlstore/supplier.go:224”,“m  
Jun 28 13:58:11 matterweb platform[78]: {“level”:“error”,“ts”:1561730291.9807322,“caller”:“sqlstore/supplier.go:236”,”  
Jun 28 13:58:21 matterweb platform[78]: {“level”:“info”,“ts”:1561730301.981353,“caller”:“sqlstore/supplier.go:224”,“ms  
Jun 28 13:58:21 matterweb platform[78]: {“level”:“error”,“ts”:1561730301.9849637,“caller”:“sqlstore/supplier.go:232”,”  
Jun 28 13:58:23 matterweb systemd[1]: mattermost.service: Main process exited, code=exited, status=102/n/a  
Jun 28 13:58:23 matterweb systemd[1]: mattermost.service: Failed with result ‘exit-code’.

Any ideas?

Thanks

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [July 3, 2019, 12:05am UTC](https://forum.mattermost.com/t/502-bad-gateway-using-ubuntu-ansible-lxc-nginx-and-mattermost/7572/2 "2019-07-03T00:05:58Z")

</div>

Hi @jcurt11n,

As a first step, some of these earlier threads might help:

- [[SOLVED] Mattermost server not starting after upgrade (4.5.0 to 4.6.1)](https://forum.mattermost.com/t/solved-mattermost-server-not-starting-after-upgrade-4-5-0-to-4-6-1/4472)
- [[SOLVED] Start MM via systemd ubuntu 16.04](https://forum.mattermost.com/t/solved-start-mm-via-systemd-ubuntu-16-04/1521)
- [https://github.com/mattermost/mattermost-server/issues/1953](https://github.com/mattermost/mattermost-server/issues/1953)
- [[SOLVED] NGINX Mattermost: 502 Bad gateway](https://forum.mattermost.com/t/solved-nginx-mattermost-502-bad-gateway/2653)
- [Mattermost stops working 502 Gateway error - backups also will not work](https://forum.mattermost.com/t/mattermost-stops-working-502-gateway-error-backups-also-will-not-work/3700)

---

<div class="post-metadata">

**Author:** ![jcurt11n](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jcurt11n](https://forum.mattermost.com/u/jcurt11n)\
**Post date:** [July 8, 2019, 5:58pm UTC](https://forum.mattermost.com/t/502-bad-gateway-using-ubuntu-ansible-lxc-nginx-and-mattermost/7572/3 "2019-07-08T17:58:13Z")

</div>

Thanks for those links. Unfortunately, the solution to my problem was stated in those links.

---

<div class="post-metadata">

**Author:** ![jcurt11n](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jcurt11n](https://forum.mattermost.com/u/jcurt11n)\
**Post date:** [July 9, 2019, 12:50pm UTC](https://forum.mattermost.com/t/502-bad-gateway-using-ubuntu-ansible-lxc-nginx-and-mattermost/7572/4 "2019-07-09T12:50:04Z")

</div>

Sorry about that mistype, the links did not provide me with a solution.

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [July 10, 2019, 11:04pm UTC](https://forum.mattermost.com/t/502-bad-gateway-using-ubuntu-ansible-lxc-nginx-and-mattermost/7572/5 "2019-07-10T23:04:50Z")

</div>

Hi @jcurt11n, would you be open to providing your complete log file?

---

<div class="post-metadata">

**Author:** ![jcurt11n](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jcurt11n](https://forum.mattermost.com/u/jcurt11n)\
**Post date:** [July 11, 2019, 1:47pm UTC](https://forum.mattermost.com/t/502-bad-gateway-using-ubuntu-ansible-lxc-nginx-and-mattermost/7572/6 "2019-07-11T13:47:21Z")

</div>

Thanks Amy.

Here are the mattermost and nginx logs and config files.

Regards,

Jim Curtin

(Attachment mattermost\_logs.zip is missing)

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [July 11, 2019, 2:14pm UTC](https://forum.mattermost.com/t/502-bad-gateway-using-ubuntu-ansible-lxc-nginx-and-mattermost/7572/7 "2019-07-11T14:14:26Z")

</div>

@jcurt11n I think you will have to attach it directly in Forum.

---

<div class="post-metadata">

**Author:** ![jcurt11n](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jcurt11n](https://forum.mattermost.com/u/jcurt11n)\
**Post date:** [July 11, 2019, 3:17pm UTC](https://forum.mattermost.com/t/502-bad-gateway-using-ubuntu-ansible-lxc-nginx-and-mattermost/7572/8 "2019-07-11T15:17:57Z")

</div>

OK here is the mattermost log and config.json.

Thanks for your help.

mattermost log:

* * *

{“level”:“info”,“ts”:1562850598.102926,“caller”:“utils/i18n.go:83”,“msg”:“Loaded system translations for ‘en’ from ‘/home/mattermost/mattermost\_app/i18n/en.json’”}  
{“level”:“info”,“ts”:1562850598.1063418,“caller”:“app/server\_app\_adapters.go:58”,“msg”:“Server is initializing…”}  
{“level”:“info”,“ts”:1562850598.1609452,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850598.1653557,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850608.166153,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850608.166689,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850618.167426,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850618.1679726,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850628.1689749,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850628.169536,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850638.2007537,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850638.2027361,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850648.2031746,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850648.2036648,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850658.2050395,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850658.2057145,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850668.2059548,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850668.2067046,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850678.2078822,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850678.2083576,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850688.2088242,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850688.209368,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850698.2104292,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850698.2109432,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850708.211846,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850708.2125547,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850718.216654,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850718.2212,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850728.2231894,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850728.2239838,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850738.2246442,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850738.2255247,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850748.2289753,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850748.229754,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850758.2301006,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850758.230944,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB retrying in 10 seconds err=dial tcp 127.0.0.1:5432: connect: connection refused”}  
{“level”:“info”,“ts”:1562850768.2320561,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL master database”}  
{“level”:“error”,“ts”:1562850768.2327633,“caller”:“sqlstore/supplier.go:232”,“msg”:“Failed to ping DB, server will exit err=dial tcp 127.0.0.1:5432: connect: connection refused”}

* * *

config.json

* * *

{  
“ServiceSettings”: {  
“SiteURL”: “”,  
“WebsocketURL”: “”,  
“LicenseFileLocation”: “”,  
“ListenAddress”: “127.0.0.1:8065”,  
“ConnectionSecurity”: “”,  
“TLSCertFile”: “”,  
“TLSKeyFile”: “”,  
“TLSMinVer”: “1.2”,  
“TLSStrictTransport”: false,  
“TLSStrictTransportMaxAge”: 63072000,  
“TLSOverwriteCiphers”: [],  
“UseLetsEncrypt”: false,  
“LetsEncryptCertificateCacheFile”: “./config/letsencrypt.cache”,  
“Forward80To443”: false,  
“TrustedProxyIPHeader”: [  
“X-Forwarded-For”,  
“X-Real-IP”  
],  
“ReadTimeout”: 300,  
“WriteTimeout”: 300,  
“MaximumLoginAttempts”: 10,  
“GoroutineHealthThreshold”: -1,  
“GoogleDeveloperKey”: “”,  
“EnableOAuthServiceProvider”: false,  
“EnableIncomingWebhooks”: true,  
“EnableOutgoingWebhooks”: true,  
“EnableCommands”: true,  
“EnableOnlyAdminIntegrations”: true,  
“EnablePostUsernameOverride”: false,  
“EnablePostIconOverride”: false,  
“EnableLinkPreviews”: false,  
“EnableTesting”: false,  
“EnableDeveloper”: false,  
“EnableSecurityFixAlert”: true,  
“EnableInsecureOutgoingConnections”: false,  
“AllowedUntrustedInternalConnections”: “”,  
“EnableMultifactorAuthentication”: false,  
“EnforceMultifactorAuthentication”: false,  
“EnableUserAccessTokens”: false,  
“AllowCorsFrom”: “”,  
“CorsExposedHeaders”: “”,  
“CorsAllowCredentials”: false,  
“CorsDebug”: false,  
“AllowCookiesForSubdomains”: false,  
“SessionLengthWebInDays”: 30,  
“SessionLengthMobileInDays”: 30,  
“SessionLengthSSOInDays”: 30,  
“SessionCacheInMinutes”: 10,  
“SessionIdleTimeoutInMinutes”: 43200,  
“WebsocketSecurePort”: 443,  
“WebsocketPort”: 80,  
“WebserverMode”: “gzip”,  
“EnableCustomEmoji”: false,  
“EnableEmojiPicker”: true,  
“EnableGifPicker”: false,  
“GfycatApiKey”: “2\_KtH\_W5”,  
“GfycatApiSecret”: “3wLVZPiswc3DnaiaFoLkDvB4X0IV6CpMkj4tf2inJRsBY6-FnkT08zGmppWFgeof”,  
“RestrictCustomEmojiCreation”: “all”,  
“RestrictPostDelete”: “all”,  
“AllowEditPost”: “always”,  
“PostEditTimeLimit”: -1,  
“TimeBetweenUserTypingUpdatesMilliseconds”: 5000,  
“EnablePostSearch”: true,  
“MinimumHashtagLength”: 3,  
“EnableUserTypingMessages”: true,  
“EnableChannelViewedMessages”: true,  
“EnableUserStatuses”: true,  
“ExperimentalEnableAuthenticationTransfer”: true,  
“ClusterLogTimeoutMilliseconds”: 2000,  
“CloseUnusedDirectMessages”: false,  
“EnablePreviewFeatures”: true,  
“EnableTutorial”: true,  
“ExperimentalEnableDefaultChannelLeaveJoinMessages”: true,  
“ExperimentalGroupUnreadChannels”: “disabled”,  
“ExperimentalChannelOrganization”: false,  
“ImageProxyType”: “”,  
“ImageProxyURL”: “”,  
“ImageProxyOptions”: “”,  
“EnableAPITeamDeletion”: false,  
“ExperimentalEnableHardenedMode”: false,  
“DisableLegacyMFA”: false,  
“ExperimentalStrictCSRFEnforcement”: false,  
“EnableEmailInvitations”: true,  
“ExperimentalLdapGroupSync”: false,  
“DisableBotsWhenOwnerIsDeactivated”: true,  
“EnableBotAccountCreation”: false  
},  
“TeamSettings”: {  
“SiteName”: “Mattermost”,  
“MaxUsersPerTeam”: 50,  
“EnableTeamCreation”: true,  
“EnableUserCreation”: true,  
“EnableOpenServer”: false,  
“EnableUserDeactivation”: false,  
“RestrictCreationToDomains”: “”,  
“EnableCustomBrand”: false,  
“CustomBrandText”: “”,  
“CustomDescriptionText”: “”,  
“RestrictDirectMessage”: “any”,  
“RestrictTeamInvite”: “all”,  
“RestrictPublicChannelManagement”: “all”,  
“RestrictPrivateChannelManagement”: “all”,  
“RestrictPublicChannelCreation”: “all”,  
“RestrictPrivateChannelCreation”: “all”,  
“RestrictPublicChannelDeletion”: “all”,  
“RestrictPrivateChannelDeletion”: “all”,  
“RestrictPrivateChannelManageMembers”: “all”,  
“EnableXToLeaveChannelsFromLHS”: false,  
“UserStatusAwayTimeout”: 300,  
“MaxChannelsPerTeam”: 2000,  
“MaxNotificationsPerChannel”: 1000,  
“EnableConfirmNotificationsToChannel”: true,  
“TeammateNameDisplay”: “username”,  
“ExperimentalViewArchivedChannels”: false,  
“ExperimentalEnableAutomaticReplies”: false,  
“ExperimentalHideTownSquareinLHS”: false,  
“ExperimentalTownSquareIsReadOnly”: false,  
“ExperimentalPrimaryTeam”: “”,  
“ExperimentalDefaultChannels”: []  
},  
“ClientRequirements”: {  
“AndroidLatestVersion”: “”,  
“AndroidMinVersion”: “”,  
“DesktopLatestVersion”: “”,  
“DesktopMinVersion”: “”,  
“IosLatestVersion”: “”,  
“IosMinVersion”: “”  
},  
“SqlSettings”: {  
“DriverName”: “postgres”,  
“DataSource”: “postgres://mmuser:abc123@127.0.0.1:5432/mattermost?sslmode=disable\u0026connect\_timeout=10”,  
“DataSourceReplicas”: [],  
“DataSourceSearchReplicas”: [],  
“MaxIdleConns”: 10,  
“ConnMaxLifetimeMilliseconds”: 3600000,  
“MaxOpenConns”: 10,  
“Trace”: false,  
“AtRestEncryptKey”: “4nzxs7z6c5gmfsmabe5xkike1f885op1”,  
“QueryTimeout”: 30  
},  
“LogSettings”: {  
“EnableConsole”: true,  
“ConsoleLevel”: “DEBUG”,  
“ConsoleJson”: true,  
“EnableFile”: true,  
“FileLevel”: “INFO”,  
“FileJson”: true,  
“FileLocation”: “”,  
“EnableWebhookDebugging”: true,  
“EnableDiagnostics”: true  
},  
“NotificationLogSettings”: {  
“EnableConsole”: true,  
“ConsoleLevel”: “DEBUG”,  
“ConsoleJson”: true,  
“EnableFile”: true,  
“FileLevel”: “INFO”,  
“FileJson”: true,  
“FileLocation”: “”  
},  
“PasswordSettings”: {  
“MinimumLength”: 5,  
“Lowercase”: false,  
“Number”: false,  
“Uppercase”: false,  
“Symbol”: false  
},  
“FileSettings”: {  
“EnableFileAttachments”: true,  
“EnableMobileUpload”: true,  
“EnableMobileDownload”: true,  
“MaxFileSize”: 52428800,  
“DriverName”: “local”,  
“Directory”: “./data/”,  
“EnablePublicLink”: false,  
“PublicLinkSalt”: “9mhb9duk4zg36y9jp9frjcs8r8tgffnh”,  
“InitialFont”: “luximbi.ttf”,  
“AmazonS3AccessKeyId”: “”,  
“AmazonS3SecretAccessKey”: “”,  
“AmazonS3Bucket”: “”,  
“AmazonS3Region”: “”,  
“AmazonS3Endpoint”: “[s3.amazonaws.com](http://s3.amazonaws.com)”,  
“AmazonS3SSL”: true,  
“AmazonS3SignV2”: false,  
“AmazonS3SSE”: false,  
“AmazonS3Trace”: false  
},  
“EmailSettings”: {  
“EnableSignUpWithEmail”: true,  
“EnableSignInWithEmail”: true,  
“EnableSignInWithUsername”: true,  
“SendEmailNotifications”: false,  
“UseChannelInEmailNotifications”: false,  
“RequireEmailVerification”: false,  
“FeedbackName”: “”,  
“FeedbackEmail”: “”,  
“ReplyToAddress”: "test@example.com",  
“FeedbackOrganization”: “”,  
“EnableSMTPAuth”: false,  
“SMTPUsername”: “”,  
“SMTPPassword”: “”,  
“SMTPServer”: “dockerhost”,  
“SMTPPort”: “2500”,  
“ConnectionSecurity”: “”,  
“SendPushNotifications”: false,  
“PushNotificationServer”: “”,  
“PushNotificationContents”: “generic”,  
“EnableEmailBatching”: false,  
“EmailBatchingBufferSize”: 256,  
“EmailBatchingInterval”: 30,  
“EnablePreviewModeBanner”: true,  
“SkipServerCertificateVerification”: false,  
“EmailNotificationContentsType”: “full”,  
“LoginButtonColor”: “#0000”,  
“LoginButtonBorderColor”: “#2389D7”,  
“LoginButtonTextColor”: “#2389D7”  
},  
“RateLimitSettings”: {  
“Enable”: false,  
“PerSec”: 10,  
“MaxBurst”: 100,  
“MemoryStoreSize”: 10000,  
“VaryByRemoteAddr”: true,  
“VaryByUser”: false,  
“VaryByHeader”: “”  
},  
“PrivacySettings”: {  
“ShowEmailAddress”: true,  
“ShowFullName”: true  
},  
“SupportSettings”: {  
“TermsOfServiceLink”: “[https://about.mattermost.com/default-terms/](https://about.mattermost.com/default-terms/)”,  
“PrivacyPolicyLink”: “[https://about.mattermost.com/default-privacy-policy/](https://about.mattermost.com/default-privacy-policy/)”,  
“AboutLink”: “[https://about.mattermost.com/default-about/](https://about.mattermost.com/default-about/)”,  
“HelpLink”: “[https://about.mattermost.com/default-help/](https://about.mattermost.com/default-help/)”,  
“ReportAProblemLink”: “[https://about.mattermost.com/default-report-a-problem/](https://about.mattermost.com/default-report-a-problem/)”,  
“SupportEmail”: "feedback@mattermost.com",  
“CustomTermsOfServiceEnabled”: false,  
“CustomTermsOfServiceReAcceptancePeriod”: 365  
},  
“AnnouncementSettings”: {  
“EnableBanner”: false,  
“BannerText”: “”,  
“BannerColor”: “#f2a93b”,  
“BannerTextColor”: “#333333”,  
“AllowBannerDismissal”: true  
},  
“ThemeSettings”: {  
“EnableThemeSelection”: true,  
“DefaultTheme”: “default”,  
“AllowCustomThemes”: true,  
“AllowedThemes”: []  
},  
“GitLabSettings”: {  
“Enable”: false,  
“Secret”: “”,  
“Id”: “”,  
“Scope”: “”,  
“AuthEndpoint”: “”,  
“TokenEndpoint”: “”,  
“UserApiEndpoint”: “”  
},  
“GoogleSettings”: {  
“Enable”: false,  
“Secret”: “”,  
“Id”: “”,  
“Scope”: “profile email”,  
“AuthEndpoint”: “[https://accounts.google.com/o/oauth2/v2/auth](https://accounts.google.com/o/oauth2/v2/auth)”,  
“TokenEndpoint”: “[https://www.googleapis.com/oauth2/v4/token](https://www.googleapis.com/oauth2/v4/token)”,  
“UserApiEndpoint”: “[https://www.googleapis.com/plus/v1/people/me](https://www.googleapis.com/plus/v1/people/me)”  
},  
“Office365Settings”: {  
“Enable”: false,  
“Secret”: “”,  
“Id”: “”,  
“Scope”: “User.Read”,  
“AuthEndpoint”: “[https://login.microsoftonline.com/common/oauth2/v2.0/authorize](https://login.microsoftonline.com/common/oauth2/v2.0/authorize)”,  
“TokenEndpoint”: “[https://login.microsoftonline.com/common/oauth2/v2.0/token](https://login.microsoftonline.com/common/oauth2/v2.0/token)”,  
“UserApiEndpoint”: “[https://graph.microsoft.com/v1.0/me](https://graph.microsoft.com/v1.0/me)”  
},  
“LdapSettings”: {  
“Enable”: false,  
“EnableSync”: false,  
“LdapServer”: “”,  
“LdapPort”: 389,  
“ConnectionSecurity”: “”,  
“BaseDN”: “”,  
“BindUsername”: “”,  
“BindPassword”: “”,  
“UserFilter”: “”,  
“GroupFilter”: “”,  
“GroupDisplayNameAttribute”: “”,  
“GroupIdAttribute”: “”,  
“FirstNameAttribute”: “”,  
“LastNameAttribute”: “”,  
“EmailAttribute”: “”,  
“UsernameAttribute”: “”,  
“NicknameAttribute”: “”,  
“IdAttribute”: “”,  
“PositionAttribute”: “”,  
“LoginIdAttribute”: “”,  
“SyncIntervalMinutes”: 60,  
“SkipCertificateVerification”: false,  
“QueryTimeout”: 60,  
“MaxPageSize”: 0,  
“LoginFieldName”: “”,  
“LoginButtonColor”: “#0000”,  
“LoginButtonBorderColor”: “#2389D7”,  
“LoginButtonTextColor”: “#2389D7”  
},  
“ComplianceSettings”: {  
“Enable”: false,  
“Directory”: “./data/”,  
“EnableDaily”: false  
},  
“LocalizationSettings”: {  
“DefaultServerLocale”: “en”,  
“DefaultClientLocale”: “en”,  
“AvailableLocales”: “”  
},  
“SamlSettings”: {  
“Enable”: false,  
“EnableSyncWithLdap”: false,  
“EnableSyncWithLdapIncludeAuth”: false,  
“Verify”: false,  
“Encrypt”: false,  
“IdpUrl”: “”,  
“IdpDescriptorUrl”: “”,  
“AssertionConsumerServiceURL”: “”,  
“ScopingIDPProviderId”: “”,  
“ScopingIDPName”: “”,  
“IdpCertificateFile”: “”,  
“PublicCertificateFile”: “”,  
“PrivateKeyFile”: “”,  
“IdAttribute”: “”,  
“FirstNameAttribute”: “”,  
“LastNameAttribute”: “”,  
“EmailAttribute”: “”,  
“UsernameAttribute”: “”,  
“NicknameAttribute”: “”,  
“LocaleAttribute”: “”,  
“PositionAttribute”: “”,  
“LoginButtonText”: “With SAML”,  
“LoginButtonColor”: “#34a28b”,  
“LoginButtonBorderColor”: “#2389D7”,  
“LoginButtonTextColor”: “#ffffff”  
},  
“NativeAppSettings”: {  
“AppDownloadLink”: “[https://about.mattermost.com/downloads/](https://about.mattermost.com/downloads/)”,  
“AndroidAppDownloadLink”: “[https://about.mattermost.com/mattermost-android-app/](https://about.mattermost.com/mattermost-android-app/)”,  
“IosAppDownloadLink”: “[https://about.mattermost.com/mattermost-ios-app/](https://about.mattermost.com/mattermost-ios-app/)”  
},  
“ClusterSettings”: {  
“Enable”: false,  
“ClusterName”: “”,  
“OverrideHostname”: “”,  
“UseIpAddress”: true,  
“UseExperimentalGossip”: false,  
“ReadOnlyConfig”: true,  
“GossipPort”: 8074,  
“StreamingPort”: 8075,  
“MaxIdleConns”: 100,  
“MaxIdleConnsPerHost”: 128,  
“IdleConnTimeoutMilliseconds”: 90000  
},  
“MetricsSettings”: {  
“Enable”: false,  
“BlockProfileRate”: 0,  
“ListenAddress”: “:8067”  
},  
“ExperimentalSettings”: {  
“ClientSideCertEnable”: false,  
“ClientSideCertCheck”: “secondary”,  
“EnableClickToReply”: false,  
“LinkMetadataTimeoutMilliseconds”: 5000,  
“RestrictSystemAdmin”: false  
},  
“AnalyticsSettings”: {  
“MaxUsersForStatistics”: 2500  
},  
“ElasticsearchSettings”: {  
“ConnectionUrl”: “[http://dockerhost:9200](http://dockerhost:9200)”,  
“Username”: “elastic”,  
“Password”: “changeme”,  
“EnableIndexing”: false,  
“EnableSearching”: false,  
“EnableAutocomplete”: false,  
“Sniff”: true,  
“PostIndexReplicas”: 1,  
“PostIndexShards”: 1,  
“ChannelIndexReplicas”: 1,  
“ChannelIndexShards”: 1,  
“UserIndexReplicas”: 1,  
“UserIndexShards”: 1,  
“AggregatePostsAfterDays”: 365,  
“PostsAggregatorJobStartTime”: “03:00”,  
“IndexPrefix”: “”,  
“LiveIndexingBatchSize”: 1,  
“BulkIndexingTimeWindowSeconds”: 3600,  
“RequestTimeoutSeconds”: 30  
},  
“DataRetentionSettings”: {  
“EnableMessageDeletion”: false,  
“EnableFileDeletion”: false,  
“MessageRetentionDays”: 365,  
“FileRetentionDays”: 365,  
“DeletionJobStartTime”: “02:00”  
},  
“MessageExportSettings”: {  
“EnableExport”: false,  
“ExportFormat”: “actiance”,  
“DailyRunTime”: “01:00”,  
“ExportFromTimestamp”: 0,  
“BatchSize”: 10000,  
“GlobalRelaySettings”: {  
“CustomerType”: “A9”,  
“SmtpUsername”: “”,  
“SmtpPassword”: “”,  
“EmailAddress”: “”  
}  
},  
“JobSettings”: {  
“RunJobs”: true,  
“RunScheduler”: true  
},  
“PluginSettings”: {  
“Enable”: true,  
“EnableUploads”: false,  
“EnableHealthCheck”: true,  
“Directory”: “./plugins”,  
“ClientDirectory”: “./client/plugins”,  
“Plugins”: {},  
“PluginStates”: {  
“com.mattermost.nps”: {  
“Enable”: true  
}  
}  
},  
“DisplaySettings”: {  
“CustomUrlSchemes”: [],  
“ExperimentalTimezone”: false  
},  
“ImageProxySettings”: {  
“Enable”: false,  
“ImageProxyType”: “local”,  
“RemoteImageProxyURL”: “”,  
“RemoteImageProxyOptions”: “”  
}  
}

---

<div class="post-metadata">

**Author:** ![paulrothrock](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/paulrothrock/32/2967_2.png) [@paulrothrock](https://forum.mattermost.com/u/paulrothrock)\
**Post date:** [July 16, 2019, 12:18am UTC](https://forum.mattermost.com/t/502-bad-gateway-using-ubuntu-ansible-lxc-nginx-and-mattermost/7572/9 "2019-07-16T00:18:48Z")

</div>

Hi @jcurt11n,

Based on your logs it looks like Mattermost isn’t able to connect to your database. Verify that your DB server is running and that the connection string in your config file under `SqlSettings`\>`DataSource` is correct.
