#Postgrex error when mix ecto.create in Windows
27 messages · Page 1 of 1 (latest)
the error is very clear: you're using the wrong password to conenct to your postgres server. The password is defined in config/dev.exs when running in local dev mode.
this is what I have inside dev.exs
import Config
# Configure your database
config :test_app, TestApp.Repo,
username: "postgres",
password: "postgres",
hostname: "localhost",
database: "test_app_dev",
stacktrace: true,
show_sensitive_data_on_connection_error: true,
pool_size: 10```
That's the default, you have to configure it depending on your postgres server setup.
I faces another problem where I am able git clone a project (using docker) and mix ecto.create on macOS but unable to do it for windows
same issue as above (with exact same docker file and dev.exs) but can only run it on mac
the difference is how you installed and set up postgres on each machine. postgres is an external dependency to your project and it's up to you to install it and set it up correctly
oh, can this happen even with the same docker settings and dev.exs settings? sorry am a new developer, kinda confused...
it depends on a lot of factors, are you running postgres through docker or did you install postgres through some other means? e.g. on macOS maybe you used homebrew? e.g. brew install postgres
on macOS i don't have postgres installed locally, im running through docker
on windows tho I do have postgres installed locally, but i'm thinking if I do docker compose up I will be running through docker? Or am I misunderstanding here?
hmm it may seems that my local postgres installed on windows could be the issue..
try uninstalling it then and see if that helps
I don't know what your docker-compose file looks like, does it contain a postgres instance?
If it did then the hostname would be "db" or "postgres" not "localhost"
What project did you clone? Is it public?
yeah that's my thoughts too; the fact your dev.exs says hostname: "localhost" implies it's meant to connect to your local host not a docker container
my apologies,
this is the settings inside dev.exs for the cloned project which works on macOS but not on windows
username: "postgres",
password: "postgres",
hostname: "127.0.0.1"
unfortunately it's not public 😦
that's the same thing though, localhost == 127.0.0.1
yea right, not sure why it worked on macOS...
That's non-standard... usually postgres is started as it's own docker container and linked to the dev server
If you have a Dockerfile that's starting postgres in the same docker container as the elixir code, that's weird.
And as long as you're doing docker compose up on both hosts... they both run linux vms underneath so there should be no difference.
version: "3.8"
services:
database:
container_name: db-postgre
image: postgres:14.4-alpine
ports:
- 5432:5432
environment:
- POSTGRES_DB=db_dev
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- ./.postgres-data:/var/lib/postgresql/data
I'm confused how that worked at all on macos. That says that you should configured elixir to connect to hostname: "database"