Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: DB(Conn(SqlxError(PoolTimedOut)) While Starting a New Loco Project with PostgreSQL #1251

Open
mustafa-ans opened this issue Feb 10, 2025 · 5 comments

Comments

@mustafa-ans
Copy link

Content:

Description of the Issue:

I recently started a new Loco project by following the instructions provided in the documentation. Here are the steps I took:

  1. Ran the loco new command and selected:
    • App Name: testing-loco
    • Type: REST API with PostgreSQL.
  2. Configured the application using the default settings generated by Loco.
  3. Attempted to start the application using:
    cargo loco start

However, I encountered the following error during runtime:

2025-02-10T12:10:42.355974Z  INFO app: loco_rs::config: loading environment from selected_path="config\\development.yaml" environment=development
2025-02-10T12:10:42.359611Z  WARN app: loco_rs::boot: pretty backtraces are enabled (this is great for development but has a runtime cost for production. disable with `logger.pretty_backtrace` in your config yaml) environment=development
Error: DB(Conn(SqlxError(PoolTimedOut)))
error: process didn't exit successfully: `target\debug\testing-loco-cli.exe start` (exit code: 1)

Steps to Reproduce:

  1. Run loco new and select PostgreSQL as the database.
  2. Follow the setup instructions and try to start the application using cargo loco start.

Environment Details:

  • OS: Windows 10
  • Rust Version: Stable (latest)
  • Loco CLI Version: Latest (installed via cargo install loco-cli)
  • PostgreSQL Version: 15 (running locally)

Additional Notes:

  • I have ensured that my PostgreSQL server is running and accessible.
  • The database credentials in config/development.yaml are correct.
  • The complete project code is available here for reference: GitHub Repository.

Suspected Cause and Observations:
The error appears to be related to SQLx's connection pool timing out while waiting for an open connection. This could be due to:

  1. Incorrect database configuration in pg_hba.conf or postgresql.conf.
  2. Missing or incorrect connection parameters in DATABASE_URL.
  3. Lack of proper timeout settings in the application.

Request for Help:
Could you please help identify:

  1. Whether this is a bug in Loco or a misconfiguration on my end?
  2. Any specific steps to resolve this issue?

I am happy to provide further details if needed

@kaplanelad
Copy link
Contributor

cargo install loco-cli is deprecated.

please run cargo install loco

@mustafa-ans
Copy link
Author

Okay I removed loco and repeated the steps to set it up, only this time I installed it using cargo install loco and I am getting the same error:

Image

Meanwhile the development.yaml has my local postgres db url within as:

Image

@kaplanelad
Copy link
Contributor

How do you run PostgreSQL locally?

@mustafa-ans
Copy link
Author

I have installed it locally using the official package installation .exe file on my machine

@kaplanelad
Copy link
Contributor

Do you also run your project directly from your machine?

Have you verified that the connection string is valid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants