sea-orm: CLI unable to connect to psql via localhost

Description

I am unable to connect to my psql database through the fly.io proxy. Instead it just times out

Steps to Reproduce

  1. run the fly.io proxy which proxies to a db hosted by fly-io (ie fly proxy 5432 -a <app>-db)
  2. export DATABASE_URL=postgres://<app>:<redacted>@localhost:5432/<app>?sslmode=disable
  3. sea-orm-cli generate entity -o src/entities

Expected Behavior

the CLI should be able to connect to the db and generate entities

Actual Behavior

Timeout

❯ RUST_LOG=trace sea-orm-cli generate entity -o src/entities -v
Connecting to Postgres ...
pool timed out while waiting for an open connection

Reproduces How Often

always

Workarounds

unable to work around

Reproducible Example

N/A

Versions

❯ cargo tree | grep sea-
├── sea-orm v0.12.3
│   ├── sea-orm-macros v0.12.3 (proc-macro)
│   │   ├── sea-bae v0.2.0 (proc-macro)
│   ├── sea-query v0.30.2
│   ├── sea-query-binder v0.5.0
│   │   ├── sea-query v0.30.2 (*)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve switched to rancher desktop from docker desktop recently and since I also got the timeout error from sea-orm-cli generate entity. It also only happens with sea-orm-cli, sqlx cli works as expected. Fortunately I just tried using 127.0.0.1 and it also fixes it for me.

So I think this must be the same issue.

So, to reproduce you could

  1. Install rancher desktop
  2. Start postgres with this docker-compose.yml:
services:
  postgres:
    image: postgres:15-alpine
    environment:
      POSTGRES_PASSWORD: mysecretpassword
    ports:
      - 5432:5432
docker compose up -d
  1. have a .env file with:
DATABASE_URL=postgres://postgres:mysecretpassword@localhost:5432/postgres
  1. Try running sea-orm-cli generate entity

That’s interesting finding, thanks.

Some other info I’ve uncovered - this only breaks with @localhost not @127.0.0.1, and only with the async-std feature turned on (which is the default). With tokio localhost works fine