# How to change a site setting via the Console

**URL:** https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761
**Category:** Support
**Created:** [August 31, 2015, 9:29pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761 "2015-08-31T21:29:26Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [August 31, 2015, 9:29pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/1 "2015-08-31T21:29:26Z")

</div>

So while investigating  
[https://meta.discourse.org/t/logout-menu-item/32731/21?u=cpradio](https://meta.discourse.org/t/logout-menu-item/32731/21)

I enabled SSO, then logged out (yikes!), and now I can’t log back in, as it wants me to use SSO to do so ☹

How can I disable the `enable_sso` site setting so I can get back into my local environment?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [August 31, 2015, 9:31pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/2 "2015-08-31T21:31:06Z")

</div>

in your `/discourse`

```plaintext
bundle exec rails c
SiteSetting.enable_sso = false

```

😉

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [August 31, 2015, 9:33pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/3 "2015-08-31T21:33:34Z")

</div>

Ah, I did it a different route, but yours is easier. 😄

I ended up doing

```plaintext
s = SiteSetting.find_by(name: 'enable_sso')  
s.value = 'f'  
s.save!  

```

I was just about to post that here and saw your response. Thanks! Now I can at least constantly get back to a good state between tests 😄 (or maybe I should setup an actual SSO…)

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [August 31, 2015, 9:42pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/4 "2015-08-31T21:42:34Z")

</div>

For future reference, visit `/u/admin-login`

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [August 31, 2015, 10:13pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/5 "2015-08-31T22:13:06Z")

</div>

Yeah just use `/users/admin-login`

---

<div class="post-metadata">

### Author: ![Svancara](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/svancara/32/36089_2.png) [@Svancara](https://meta.discourse.org/u/Svancara)
#### Post date: [September 2, 2015, 3:13pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/6 "2015-09-02T15:13:26Z")

</div>

I did

`SiteSetting.enable_sso = false`

But I ended up with this login form:

 ![](https://global.discourse-cdn.com/meta/original/3X/1/b/1bef01f786a0b150a0720f669145378fec5d5501.png) 

How can I log-in please?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [September 2, 2015, 5:35pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/7 "2015-09-02T17:35:55Z")

</div>

Looks like you have no login methods available.

Do `SiteSetting.enable_local_logins = true` .

---

<div class="post-metadata">

### Author: ![Svancara](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/svancara/32/36089_2.png) [@Svancara](https://meta.discourse.org/u/Svancara)
#### Post date: [September 2, 2015, 5:48pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/8 "2015-09-02T17:48:41Z")

</div>

Yes!

Thank you very much!

---

<div class="post-metadata">

### Author: ![ewanly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ewanly/32/62854_2.png) [@ewanly](https://meta.discourse.org/u/ewanly)
#### Post date: [October 19, 2016, 1:02pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/9 "2016-10-19T13:02:52Z")

</div>

After running : “bundle exec rails c”  
I’m getting an error : “Could not locate Gemfile”

How to fix it?

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [October 19, 2016, 1:46pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/10 "2016-10-19T13:46:08Z")

</div>

Are you running this from inside your container (`./launcher enter app`)?

---

<div class="post-metadata">

### Author: ![ewanly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ewanly/32/62854_2.png) [@ewanly](https://meta.discourse.org/u/ewanly)
#### Post date: [October 19, 2016, 1:52pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/11 "2016-10-19T13:52:46Z")

</div>

No I wasn’t 😊 since its wasn’t mentioned. Sorry a lot of things to learn yet 👽

---

<div class="post-metadata">

### Author: ![ewanly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ewanly/32/62854_2.png) [@ewanly](https://meta.discourse.org/u/ewanly)
#### Post date: [October 19, 2016, 2:46pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/12 "2016-10-19T14:46:20Z")

</div>

So I did these commands:

```
cd /var/discourse
./launcher enter app

```

then  
`bundle exec rails c`

and I’ve got the following errors:

> URGENT: FATAL: Peer authentication failed for user “discourse”  
> Failed to initialize site default  
> /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active\_record/connection\_adapters/postgresql\_adapter.rb:651:in `initialize': FATAL: Peer authentication failed for user "discourse" (PG::ConnectionBad) from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new’  
> from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active\_record/connection\_adapters/postgresql\_adapter.rb:651:in `connect’

> …  
> … many folders list  
> …

I did `./launcher rebuild app` and tried again. The same errors!

* * *

After I’d pissed of these problems. I did restored my droplet from a previous snapshot I had and started from scratch.

I did enabled FORCE\_HTTPS without a problem.

---

<div class="post-metadata">

### Author: ![Alavi1412](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alavi1412/32/67721_2.png) [@Alavi1412](https://meta.discourse.org/u/Alavi1412)
#### Post date: [December 29, 2016, 4:03pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/14 "2016-12-29T16:03:05Z")

</div>

Can we change the discourse language in `bundle exec rails c` console?  
How can we change the language of our site to english?

---

<div class="post-metadata">

### Author: ![Alavi1412](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alavi1412/32/67721_2.png) [@Alavi1412](https://meta.discourse.org/u/Alavi1412)
#### Post date: [December 31, 2016, 7:45am UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/15 "2016-12-31T07:45:39Z")

</div>

changing language can be done in database in site\_settings column.  
just search the current language and replace new language:  
below code change language from Farsi to english:  
`UPDATE site_setting SET value = 'en' where value = 'fa_IR'`  
I have typed this code after typing : `rails db`

---

<div class="post-metadata">

### Author: ![metakermit](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/metakermit/32/119609_2.png) [@metakermit](https://meta.discourse.org/u/metakermit)
#### Post date: [April 4, 2018, 12:36pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/16 "2018-04-04T12:36:05Z")

</div>

I had a problem with the `force_https` option (couldn’t login after enabling it). I fixed it by doing:

```plaintext
cd /var/discourse/
./launcher enter app
rails c
[1] pry(main)> SiteSetting.force_https = false
=> false

```

---

<div class="post-metadata">

### Author: ![Dannii](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dannii/32/129087_2.png) [@Dannii](https://meta.discourse.org/u/Dannii)
#### Post date: [September 12, 2019, 4:01am UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/17 "2019-09-12T04:01:57Z")

</div>

I believe a setting regex needs updating, and want to test with a new value, but when I go `SiteSetting.key = value` it blocks me because of the regex. Is there a way to force update a value even if it doesn’t match the setting’s regex?

Edit: this worked, though be very careful!

```plaintext
cd /var/discourse/
./launcher enter app
rails db
discourse=> update site_settings set value='newvalue' where name='settingname';

```

And then exit out, and restart the app:

```plaintext
./launcher stop app
./launcher start app

```

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [September 28, 2019, 3:59pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/18 "2019-09-28T15:59:41Z")

</div>

`./launcher restart app` is slightly faster to restart the app 😉

---

<div class="post-metadata">

### Author: ![Artem\_Vasiliev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/artem_vasiliev/32/175226_2.png) [@Artem\_Vasiliev](https://meta.discourse.org/u/Artem_Vasiliev)
#### Post date: [April 1, 2020, 2:55pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/19 "2020-04-01T14:55:11Z")

</div>

Just in case, here’s a shell script oneliner not requiring to restart Discourse: `bundle exec rails runner "SiteSetting.set('enable_sso', false)"`. It works just like it would from Discourse Admin UI.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [July 4, 2024, 9:49pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/23 "2024-07-04T21:49:43Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [July 4, 2024, 9:52pm UTC](https://meta.discourse.org/t/how-to-change-a-site-setting-via-the-console/32761/24 "2024-07-04T21:52:18Z")

</div>


