Db connection error while setting up phoenix on crostini (linux container on chromeos)

I read from other posts with this same error that perhaps the host-name should match the name of the container (though they used docker not an lxc container), so I tried changing the following:

in config.exs
url: [host: "penguin"]
in dev.exs
hostname: "penguin"
http: [ip: {127, 0, 0, 1}, port: 4000]

in etc/hosts
127.0.1.1 arch // artifact from linux installation?
127.0.0.1 penguin // i added this

(penguin is the name of the default container with linux on chromeos)

but then again, since i’m just starting, so I have no idea what i’m doing. :woozy_face: I’m just trying to finish the “up and running” part of the tutorial!

mix ecto.create
Compiling 15 files (.ex)
Generated mapping_app_base app

04:44:04.497 [error] Postgrex.Protocol (#PID<0.335.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (arch:5432): connection refused - :econnrefused

04:44:04.517 [error] Postgrex.Protocol (#PID<0.341.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (arch:5432): connection refused - :econnrefused
** (Mix) The database for MappingAppBase.Repo couldn't be created: killed

okay. my bad. I guess while following the up 'n running section of the tutorial I didn’t expect to set up database stuff myself. I thought ecto.create did that!

my notes:

# for archlinux
# follow https://wiki.archlinux.org/title/PostgreSQL
sudo -i -u postgres
initdb -D /var/lib/postgres/data
pg_ctl -D /var/lib/postgres/data -l logfile start
#pg_ctl -D /var/lib/postgres/data start
exit

# if lockfile error on /var/run/postgresql...
# https://stackoverflow.com/questions/22851352/postgresql-server-failed-to-start-could-not-create-lock-file-permission-denied 
mkdir /var/run/postgresql
sudo -i -u postgres
chown -R postgres:postgres /var/run/postgresql
exit

# can use env vars PGHOST 'n PGPORT
# see defaults here: /var/lib/postgres/data/postgresql.conf

sudo systemctl start postgresql.service
#sudo systemctl enable postgresql.service

mix ecto.create

Phoenix compared to rails, favors postgres as the default database type for ecto.

You can always switch this by passing the --database option, if you want for example a sqlite database.

yeah, I dunno anything about databases nowadays, but i’m cool with the defaults; besides, it gives the option of using supabase if I don’t want to deal with it. :slight_smile:

what’s really fantastic is that i’m able to reach the example web-site on the server, which is run in a container, from the chromeos’s browser… For flutter, the tutorial told me to install another browser in the container :woozy_face:. Or maybe it does work for flutter, and it was recommended for debugging via chrome debugger…? Who knows… but I’m so happy to dig into this! :smiley: