# Unable to authenticate / Error connection closed Rails

**URL:** <https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674>\
**Category:** Help me!\
**Created:** [June 11, 2021, 8:13am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674 "2021-06-11T08:13:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe\_Marc](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/joe_marc/32/1388_2.png) [@Joe\_Marc](https://community.forestadmin.com/u/Joe_Marc)\
**Post date:** [June 11, 2021, 8:13am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/1 "2021-06-11T08:13:26Z")

</div>

Hello after a year since i last updated it, i tried to log into my project as every days. But it’s not working anymore, i tried to upgrade to the last version of the gem for rails, but it’s still not working..

I get `net::ERR_CONNECTION_CLOSED` in the console as you will see into the below screenshots

## Failure Logs

 ![Capture d’écran 2021-06-11 à 09.55.44](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/a/ac55dfba8859c93fa88da852146c78fb4e304af3.png)  
 ![Capture d’écran 2021-06-11 à 09.55.53](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/6/6529fcfd946ccdebff393e869d020a462d6ededd.png)  
 ![Capture d’écran 2021-06-11 à 09.56.05](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/8/8a309301faca1802868e5b946c4498a203e29e97.png)

## Context

**My CORS config :**

```javascript

    config.middleware.insert_before 0, Rack::Cors do
      allow do
        hostnames = [null_regex, 'localhost:4200', 'app.forestadmin.com', 'localhost:3001']
        hostnames += ENV['CORS_ORIGINS'].split(',') if ENV['CORS_ORIGINS']

        origins hostnames
        resource '*',
                 headers: :any,
                 methods: %i[get post options delete put],
                 max_age: 0,
                 expose: ['Content-Disposition'],
                 credentials: true
      end
    end

```

**Forest\_liana.rb** the 3 are called on the os level for sure

```javascript
ForestLiana.env_secret = Rails.application.secrets.forest_env_secret
ForestLiana.auth_secret = Rails.application.secrets.forest_auth_secret
ForestLiana.application_url = Rails.application.secrets.forest_application_url

```

**Forest rails gem version =\> 6.0.3**

I you need more informations, feel free to ask.

Thanks for you help

---

<div class="post-metadata">

**Author:** ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)\
**Post date:** [June 11, 2021, 8:55am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/2 "2021-06-11T08:55:39Z")

</div>

Hey @Joe_Marc,

We recently had a few instabilities on the platform. May I ask you to try again now, and tell me if you are experiencing any issue?  
Also, did you follow the upgrade to v6 note available [here](https://docs.forestadmin.com/documentation/how-tos/maintain/upgrade-notes-rails/upgrade-to-v6)?

If possible, could you also share your project name?

Thanks in advance 🙏

---

<div class="post-metadata">

**Author:** ![Joe\_Marc](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/joe_marc/32/1388_2.png) [@Joe\_Marc](https://community.forestadmin.com/u/Joe_Marc)\
**Post date:** [June 11, 2021, 9:31am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/3 "2021-06-11T09:31:54Z")

</div>

Hey @anon39848301

Thanks for your answer. I’ve tried again, and it’s still not working … 😕 ( still the same errors)

Yes i followed the steps of the updates except the static client id because i don’t think i need it ( maybe i’m wrong)

Project name is _ **MonsieurJeanAdmin** _

Thanks in advance

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [June 11, 2021, 11:36am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/4 "2021-06-11T11:36:27Z")

</div>

Hello @Joe_Marc,

I think there is an extra point at the end of the remote address you configured for your remote environment. Forest Admin is trying to contact `https://api-staging.waiter.fr./forest/authentication` which does not look like a valid URL.

Can you change the configuration of this remote environment and fix the URL?

---

<div class="post-metadata">

**Author:** ![Joe\_Marc](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/joe_marc/32/1388_2.png) [@Joe\_Marc](https://community.forestadmin.com/u/Joe_Marc)\
**Post date:** [June 11, 2021, 2:51pm UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/5 "2021-06-11T14:51:21Z")

</div>

> [@GuillaumeGautreau](#):
>
> [https://api-staging.waiter.fr](https://api-staging.waiter.fr)./forest/authentication

Thanks for your response @GuillaumeGautreau ,  
I had an error about the url indeed with `.` at the end of my domain.  
But it does not update i still get the same error …

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [June 11, 2021, 2:54pm UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/6 "2021-06-11T14:54:57Z")

</div>

I made the change directly in our system, the extra dot was still present.

Can you refresh your browser and test again?

---

<div class="post-metadata">

**Author:** ![Joe\_Marc](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/joe_marc/32/1388_2.png) [@Joe\_Marc](https://community.forestadmin.com/u/Joe_Marc)\
**Post date:** [June 11, 2021, 2:57pm UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/7 "2021-06-11T14:57:51Z")

</div>

Thanks for the update, i have the same error but without the dot now !  
`https://api-staging.waiter.fr/forest/authentification`

I don’t really understand it since i don’t manage the endpoints `/forest`

My backend works fine at `https://api-staging.waiter.fr`

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [June 11, 2021, 3:23pm UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/8 "2021-06-11T15:23:21Z")

</div>

Can you share the detail about the new error?

- Which HTTP requests are failing?
- Can you share details about these requests & received response?

---

<div class="post-metadata">

**Author:** ![Joe\_Marc](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/joe_marc/32/1388_2.png) [@Joe\_Marc](https://community.forestadmin.com/u/Joe_Marc)\
**Post date:** [June 11, 2021, 3:52pm UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/9 "2021-06-11T15:52:49Z")

</div>

Yes here is the error in the console :

 ![Capture d’écran 2021-06-11 à 17.51.23](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/f/f2da2f5b39a608948a27285629a69fd48b2ee3d5.png)

And here are the lgos of the received response :

```javascript
The registration to the authentication API failed, response: {\"error\":\"invalid_redirect_uri\",\"error_description\":\"Redirect uris must be an array of valid urls. Received: \\\"\\\".\"}

```

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [June 14, 2021, 6:43am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/10 "2021-06-14T06:43:05Z")

</div>

Ok, thanks for sharing this error.

It seems that there is an error with the secret named `forest_application_url`. Can you check that its value is correctly configured with `https://api-staging.waiter.fr` in yout `secrets.yml`?

---

<div class="post-metadata">

**Author:** ![Joe\_Marc](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/joe_marc/32/1388_2.png) [@Joe\_Marc](https://community.forestadmin.com/u/Joe_Marc)\
**Post date:** [June 14, 2021, 7:00am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/11 "2021-06-14T07:00:47Z")

</div>

Hello,

Yes the value is configured in the vars of heroku as i always do.

 ![Capture d’écran 2021-06-14 à 09.00.03](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/6/6e912a3490b2f027e16a14f38035f49021793266.png)  
 ![Capture d’écran 2021-06-14 à 08.59.46](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/5/544fb8e3696270e54e6aeb7bf9c6e794358357f1.png)

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [June 14, 2021, 7:04am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/12 "2021-06-14T07:04:46Z")

</div>

The error you received indicates that this value was not correctly loaded by the application. Can you check that your application correctly receives this value, and uses it?

In the file `config/initializers/forest_liana.rb` you should have these 3 lines:

```javascript
ForestLiana.env_secret = Rails.application.secrets.forest_env_secret
ForestLiana.auth_secret = Rails.application.secrets.forest_auth_secret
ForestLiana.application_url = Rails.application.secrets.forest_application_url

```

---

<div class="post-metadata">

**Author:** ![Joe\_Marc](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/joe_marc/32/1388_2.png) [@Joe\_Marc](https://community.forestadmin.com/u/Joe_Marc)\
**Post date:** [June 14, 2021, 7:06am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/13 "2021-06-14T07:06:00Z")

</div>

Yes i have them 🙂

 ![Capture d’écran 2021-06-14 à 09.05.36](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/e/e0e2e0ab635f98e3c03e22c163f5aa8baf3cb4a5.png)

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [June 14, 2021, 8:02am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/14 "2021-06-14T08:02:56Z")

</div>

Do you have a way to log the value that is set to `ForestLiana.application_url`? I’d like to be sure that the value is correct, because the error that is returned by the server clearly indicates that the string received is `\"\"`

---

<div class="post-metadata">

**Author:** ![Joe\_Marc](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/joe_marc/32/1388_2.png) [@Joe\_Marc](https://community.forestadmin.com/u/Joe_Marc)\
**Post date:** [June 14, 2021, 8:24am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/15 "2021-06-14T08:24:58Z")

</div>

![Capture d’écran 2021-06-14 à 10.23.41](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/5/50a1830ad31826bd84e782a07d8ba0a277b71de7.png)

I just logged it from heroku and i get the value.  
Yes in the network response of the server the value is empty … i don’t understand why

```javascript
The registration to the authentication API failed, response: {\"error\":\"invalid_redirect_uri\",\"error_description\":\"Redirect uris must be an array of valid urls. Received: \\\"\\\".\"}"

```

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [June 14, 2021, 8:41am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/16 "2021-06-14T08:41:02Z")

</div>

ok, here you retrieved the environment variable set on heroku.

I would like to be sure that the application itself and the liana is using the right value. I would like to be sure that `ForestLiana.application_url` is really equal to this value.

In addition to that, I find it strange that the value that is logged here is not exactly the same than the one you shared before: there is an extra slash at the end.

---

<div class="post-metadata">

**Author:** ![Joe\_Marc](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/joe_marc/32/1388_2.png) [@Joe\_Marc](https://community.forestadmin.com/u/Joe_Marc)\
**Post date:** [June 14, 2021, 8:43am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/17 "2021-06-14T08:43:10Z")

</div>

Yes because i tried to update it ( sorry for not mentionning it )

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [June 14, 2021, 8:43am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/18 "2021-06-14T08:43:58Z")

</div>

Can you find a way to log the value of `ForestLiana.application_url ` and check that its value is correct?

---

<div class="post-metadata">

**Author:** ![Joe\_Marc](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/joe_marc/32/1388_2.png) [@Joe\_Marc](https://community.forestadmin.com/u/Joe_Marc)\
**Post date:** [June 14, 2021, 8:49am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/19 "2021-06-14T08:49:07Z")

</div>

For now i’m trying to find a way to log the value 🙂

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [June 14, 2021, 8:52am UTC](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674/20 "2021-06-14T08:52:21Z")

</div>

If you use `puts`, I guess that the line should appear in logs on heroku (you can access them on the web interface, or with the CLI)

[Next page](https://community.forestadmin.com/t/unable-to-authenticate-error-connection-closed-rails/2674.md?page=2)
