vapor / fluent-postgres-driver

🐘 PostgreSQL driver for Fluent.
MIT License
146 stars 53 forks source link

PSQLError: Opening new connection for pool failed #216

Closed BackWorld closed 9 months ago

BackWorld commented 9 months ago

Versions

.package(url: "https://github.com/vapor/fluent.git", from: "4.8.0"), .package(url: "https://github.com/vapor/fluent-postgres-driver.git", from: "2.7.2"),

Describe the bug

[ ERROR ] Opening new connection for pool failed: PSQLError(code: connectionError, underlying: NIOPosix.NIOConnectionError(host: "127.0.0.1", port: 5432, dnsAError: nil, dnsAAAAError: nil, connectionErrors: [NIOPosix.SingleConnectionFailure(target: [IPv4]127.0.0.1/127.0.0.1:5432, error: connection reset (error set): Connection refused (errno: 61))])) [database-id: psql]

[ WARNING ] PSQLError(code: connectionError, underlying: NIOPosix.NIOConnectionError(host: "127.0.0.1", port: 5432, dnsAError: nil, dnsAAAAError: nil, connectionErrors: [NIOPosix.SingleConnectionFailure(target: [IPv4]127.0.0.1/127.0.0.1:5432, error: connection reset (error set): Connection refused (errno: 61))]))

Swift/ErrorType.swift:200: Fatal error: Error raised at top level: PSQLError(code: connectionError, underlying: NIOPosix.NIOConnectionError(host: "127.0.0.1", port: 5432, dnsAError: nil, dnsAAAAError: nil, connectionErrors: [NIOPosix.SingleConnectionFailure(target: [IPv4]127.0.0.1/127.0.0.1:5432, error: connection reset (error set): Connection refused (errno: 61))]))

To Reproduce

swift run App migrate

Demo project source codes

app.databases.use(DatabaseConfigurationFactory.postgres(configuration: .init(
        hostname: Environment.get("DATABASE_HOST") ?? "localhost",
        port: Environment.get("DATABASE_PORT").flatMap(Int.init(_:)) ?? SQLPostgresConfiguration.ianaPortNumber,
        username: Environment.get("DATABASE_USERNAME") ?? "vapor_username",
        password: Environment.get("DATABASE_PASSWORD") ?? "vapor_password",
        database: Environment.get("DATABASE_NAME") ?? "vapor_database",
        tls: .disable)
    ), as: .psql)
app.migrations.add(CreateTodo())
BackWorld commented 9 months ago

Just created the demo project with the default template under vapor-cli, without anything changes!

0xTim commented 9 months ago

@BackWorld how are you running the database?

BackWorld commented 9 months ago

@0xTim Yeah! I just forgot that I wasn't running the DB with Docker. 👍 :)-