1

I am currently trying to push in production my small app, which consist of a ruby on rails back end and a react front end. I wanted to try cookie based authentication for my log in process.

When I tried the application in development mode, everything was fine. Then I try to push it on jelastic cloud to see if it was still working on the cloud but everytime I tried to create a new user or to log in with an existing user, the server returns me a 500 error.

Here are my backend configuration:

A nginx load balancing NGINX 1.22.1 node.
A NGINX 1.22.0 ruby 3.1.2 app server node
And a PostgreSQL 15.2 database node.

The first thing I did was to search into the nginx error logs the possible cause of the issue, and I found theses lines:

the log of my errors

So I thought I did not configure my postgresql database properly, but I was able to run command like : "rails db:create and rails db:migrate"

I tried to open a rails console into my rails server and to search manually for a user, and everythings was working fine.

I do not think it is a cors issues cause I am checking if the user is logged in, and this api call ( a get method) is working perfectly well. However, this function does not need the database.

I do not think either that it may be a error into my code cause everything was working well in development mode. I just do not understand why, when I use Active record from the console it is working but not when the program call it from a controller.

May it be a problem in the nginx config?

I am pretty sure that it must a stupid mistake, but after many weeks looking for it, I still have not found it.

Thank you very much.

Unik6065
  • 25
  • 5
  • 1
    How is your database hostname defined? Looks like you might not be pointing to the postgres server (which is on a separate node, and is not available via socket as mentioned in your error message) – Damien - Layershift Jun 24 '23 at 12:27
  • I define it like that: postgresql://nodeXXX. I do not think this is the problem cause I can connect to the database when I am in the rails console ( I can create/ find user into the database) and I was able to create and migrate the database (rails db:create and rails db:migrate) – Unik6065 Jun 24 '23 at 15:15
  • This sounds like a permissions issue -- the user being used for the web application does not have access to the postgres config file. How did you set the user for the application? – dbugger Jun 24 '23 at 15:45
  • I am not sure about what you mean by "The user being used for the web application". If you mean the user used for connection to the postgres node, it is the master user ( I know this is not a good practice). If you mean the User I created for my application, I am not sure to understand what the point, but I created it on the rails console. – Unik6065 Jun 24 '23 at 15:58

0 Answers0