Couldn't connect my postgress while installing medusa. #4743
-
I had already downloaded my posgresql in my computer and created the database but when i installing medusa it is not working. I'm 100% sure i'm providing the right password `PS G:\Practices\04_Medusa_experiment> yarn create medusa-app You can learn how to install PostgreSQL here: https://docs.medusajs.com/development/backend/prepare-environment?os=windows#postgresql If you keep running into this issue despite having PostgreSQL installed, please check out our troubleshooting guidelines: https://docs.medusajs.com/troubleshooting/database-error |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 12 replies
-
please check the port of PostgreSQL for medusa it should be 5432. |
Beta Was this translation helpful? Give feedback.
-
cc: @shahednasser |
Beta Was this translation helpful? Give feedback.
-
@Fardeen-Awais with the latest update of npx create-medusa-app@latest --db-url postgres:://user:password@localhost:5432/giftstore Make sure to pass the correct username, password, and port (by default it's Please note that with the latest version there's an issue with using |
Beta Was this translation helpful? Give feedback.
-
Hello, I have the same issue, but my Postgres is running in Docker. When I tested my connection via However, when I passed the same command to start a medusa project, I ran into this issue. I am currently just testing it, so my Postgres user is Anything that I missed? Thanks! |
Beta Was this translation helpful? Give feedback.
-
I was having this same problem with docker, and realized I had my local posgres for another project still running on 5432, |
Beta Was this translation helpful? Give feedback.
-
IssueNote This is a reproduction of bug #4999 Running EnvironmentVersions: OSX: 14.4 (Sonoma)
NodeJS: v21.7.1
Homebrew: 4.2.15-32
create-medusa-app: 1.2.7 Steps to reproduce
Results
npx create-medusa-app@latest --with-nextjs-starter
? What's the name of your project? my-medusa-store
? Enter an email for your admin dashboard user [email protected]
? Enter your Postgres username postgres
? Enter your Postgres password [hidden]
Couldn't connect to PostgreSQL because of the following error: error: role "postgres" does not exist.
Make sure you have PostgreSQL installed and the credentials you provided are correct.
You can learn how to install PostgreSQL here: https://docs.medusajs.com/development/backend/prepare-environment?os=macos#postgresql
If you keep running into this issue despite having PostgreSQL installed, please check out our troubleshooting guidelines: https://docs.medusajs.com/troubleshooting/database-error Expected results
SOLUTION
Important psql -U $USER -d postgres -c 'CREATE ROLE "postgres"' \
-c 'ALTER ROLE "postgres" WITH SUPERUSER INHERIT CREATEROLE CREATEDB LOGIN REPLICATION BYPASSRLS'
psql -U $USER -d postgres -c '\du'
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
${USER} | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
npx create-medusa-app@latest --with-nextjs-starter Further AnalysisNote Substitute
Potential fixes
{
type: "input",
name: "postgresDatabaseName",
message: "Enter your Postgres database name",
default: "postgres",
validate: (input) => {
return typeof input === "string" && input.length > 0
},
},
])
postgresUsername = answers.postgresUsername
postgresPassword = answers.postgresPassword
postgresDatabaseName = answers.postgresDatabaseName
|
Beta Was this translation helpful? Give feedback.
-
For anyone connecting to external postgres dn please make sure to wrap the db url in double quotes and specify the the ssl mode |
Beta Was this translation helpful? Give feedback.
-
this is the correct |
Beta Was this translation helpful? Give feedback.
@Fardeen-Awais with the latest update of
create-medusa-app
, you can set your database url by passing it as an option as follows:Make sure to pass the correct username, password, and port (by default it's
5432
).Please note that with the latest version there's an issue with using
yarn create medusa-app
. We've opened a PR to fix it, so please use npx or pnpm for now.