Connecting Postgres to Strapi from a local project

skievHOBBY

9 months ago

I am trying to deploy a Strapi project I created locally with a Postgres database deployed on Railway. To do this, I followed the configurations indicated by Strapi by creating the env and production folders, as well as database.ts and server.ts files. I added the database environment variables provided by Railway to the project's environment variables.

When running the project with npm run start for Strapi (from the local environment) to connect to the Postgres database on Railway and create the tables, I received this error:

strapi start

[2024-07-28 17:32:42.430] debug: ️ Server wasn't able to start properly. [2024-07-28 17:32:42.439] error: getaddrinfo ENOTFOUND postgres.railway.internal

[2024-07-28 17:32:42.430] debug: ️ Server wasn't able to start properly. [2024-07-28 17:32:42.439] error: getaddrinfo ENOTFOUND postgres.railway.internal [2024-07-28 17:32:42.430] debug: ️ Server wasn't able to start properly. [2024-07-28 17:32:42.439] error: getaddrinfo ENOTFOUND postgres.railway.internal [2024-07-28 17:32:42.439] error: getaddrinfo ENOTFOUND postgres.railway.internal Error: getaddrinfo ENOTFOUND postgres.railway.internal at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26)

I should mention that I performed this process several times a year ago and did not receive this error. I also noticed that when deploying a Postgres database on Railway, some things have changed since then, so I assume it might be something along those lines.

Thank you in advance.

3 Replies

9 months ago

You need to use the DATABASE_PUBLIC_URL when developing locally.


skievHOBBY

9 months ago

Oh I see. I appreciate it very much


9 months ago

Let me know if you have any further issues


Connecting Postgres to Strapi from a local project - Railway Help Station