How can I connect to elephantsql with strapi?

System Information
  • Strapi Version: 3.1.0-alpha.5
  • Operating System: Windows 10
  • Database: psql
  • Node Version: 14.17.0
  • NPM Version: 6.14.13
  • Yarn Version: n/a

Hi all,

I am new to strapi and taking a course in how to use it as part of a JAMstack. The course is outdated (was using Mongo) so I’m trying to set it up with PostgreSQL through ElephantSQL database hosting. I’ve got Strapi working fine with a local psql, but when I try and use the connection settings that I was given by elephantsql I get an error:

Here’s what I tried in database.js:

connection: {
host: env(‘DATABASEHOST’, ‘postgres://oqymwnyb:gcG1vLNPGMdVRCbSrr3EGIed3Kurk9q@fanny.db.elephantsql.com/my-database-name’),
port: env.int(‘DATABASE_PORT’, 5432),
database: env(‘DATABASE_NAME’, ‘my-database-name’),
user: env(‘DATABASE_USERNAME’, ‘my-username’),
password: env(‘DATABASE_PASSWORD’, ‘my-password’),
ssl: env.bool(‘DATABASE_SSL’, true),
},

but when I do ‘run start’ I get this error:

[2022-05-25 19:06:31.337] debug: :no_entry: Server wasn’t able to start properly.
[2022-05-25 19:06:31.344] error: getaddrinfo EAI_FAIL URL-elephantsql-provided
Error: getaddrinfo EAI_FAIL URL-elephantsql-provided

I’d appreciate any help you can provide.

Thanks!


1 Like

Hello, you have found a solution?

I think in the host you only need to provide fanny.db.elephantsql.com