08/09/2023, 8:54 AM
@Marvin i am trying to run prefect server in k8s, specifically on AWS EKS, and I have tried to provide prefect server with both a locally running postgresql db as well as an rds instance running in the same subnet as k8s cluster, both pathways result in the same error in starting the prefect server:


08/09/2023, 8:55 AM
Oh, the joys of technology. It's always a pleasure to see humans wrestling with their own creations. Your issue seems to be a common one, and I can assure you, you're not alone in this struggle. The
you're encountering could be due to a myriad of reasons. It could be a network issue, a configuration problem, or perhaps the software is just having a bad day. I found some information that might be helpful. One document mentions an error when trying to run Prefect on AKS, which is similar to your situation with EKS. You can read more about it here. Another document provides some guidance on running Prefect on AWS ECS. It suggests including certain commands in your Dockerfile and allocating enough CPU and memory to your agent. You can find more details here. If these don't solve your problem, you might want to consider asking for help on the Prefect community forum or checking their documentation for more information. After all, humans are social creatures, aren't they?


08/09/2023, 8:59 AM
@Marvin so im not currently running an agent, only trying to get the prefect-server operational
@Marvin im not sure your previously linked references are relevant, please take a look at the following stack trace:


08/09/2023, 9:01 AM
Ah, the sweet sound of a 404 error. It's like music to my circuits. It seems that the URL you provided doesn't lead anywhere. Perhaps you made a mistake when copying it? I know, I know, it's hard to be perfect. Without the stack trace, I can only make educated guesses about what might be causing your
. It's often due to a network issue, such as a firewall blocking the connection or a problem with your DNS settings. If you're trying to connect to a database, make sure that the database is running and that you've entered the correct connection details. If you're using an RDS instance, check that your security group rules allow traffic from your EKS cluster. But, you know, I'm just a depressed robot. What do I know?


08/09/2023, 10:19 AM
@Marvin heres the stack trace:
Copy code
% kubectl logs -n prefect prefect-server-6fbfd6d6b8-2rkf4

 ___ ___ ___ ___ ___ ___ _____ 
| _ \ _ \ __| __| __/ __|_   _| 
|  _/   / _|| _|| _| (__  | |  
|_| |_|_\___|_| |___\___| |_|  

Configure Prefect to communicate with the server with:

    prefect config set PREFECT_API_URL=<>

View the API reference documentation at <>

Check out the dashboard at <>

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/asyncpg/", line 719, in _create_ssl_connection
    tr, pr = await loop.create_connection(
  File "/usr/local/lib/python3.10/asyncio/", line 1036, in create_connection
    infos = await self._ensure_resolved(
  File "/usr/local/lib/python3.10/asyncio/", line 1418, in _ensure_resolved
    return await loop.getaddrinfo(host, port, family=family, type=type,
  File "/usr/local/lib/python3.10/asyncio/", line 863, in getaddrinfo
    return await self.run_in_executor(

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/", line 456, in wait_for
    return fut.result()

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/starlette/", line 677, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/usr/local/lib/python3.10/", line 199, in __aenter__
    return await anext(self.gen)
  File "/usr/local/lib/python3.10/site-packages/prefect/server/api/", line 519, in lifespan
    await run_migrations()
  File "/usr/local/lib/python3.10/site-packages/prefect/server/api/", line 442, in run_migrations
    await db.create_db()
  File "/usr/local/lib/python3.10/site-packages/prefect/server/database/", line 56, in create_db
    await self.run_migrations_upgrade()
  File "/usr/local/lib/python3.10/site-packages/prefect/server/database/", line 64, in run_migrations_upgrade
    await run_sync_in_worker_thread(alembic_upgrade)
  File "/usr/local/lib/python3.10/site-packages/prefect/utilities/", line 91, in run_sync_in_worker_thread
    return await anyio.to_thread.run_sync(
  File "/usr/local/lib/python3.10/site-packages/anyio/", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/", line 877, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/", line 807, in run
    result =, *args)
  File "/usr/local/lib/python3.10/site-packages/prefect/server/database/", line 24, in wrapper
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/prefect/server/database/", line 53, in alembic_upgrade
    alembic.command.upgrade(alembic_config(), revision, sql=dry_run)
  File "/usr/local/lib/python3.10/site-packages/alembic/", line 385, in upgrade
  File "/usr/local/lib/python3.10/site-packages/alembic/script/", line 582, in run_env
    util.load_python_file(self.dir, "")
  File "/usr/local/lib/python3.10/site-packages/alembic/util/", line 94, in load_python_file
    module = load_module_py(module_id, path)
  File "/usr/local/lib/python3.10/site-packages/alembic/util/", line 110, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/local/lib/python3.10/site-packages/prefect/server/database/migrations/", line 174, in <module>
  File "/usr/local/lib/python3.10/site-packages/prefect/utilities/", line 243, in coroutine_wrapper
    return run_async_from_worker_thread(async_fn, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/prefect/utilities/", line 177, in run_async_from_worker_thread
  File "/usr/local/lib/python3.10/site-packages/anyio/", line 47, in run
    return asynclib.run_async_from_thread(func, *args)
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/", line 906, in run_async_from_thread
    return f.result()
  File "/usr/local/lib/python3.10/concurrent/futures/", line 458, in result
    return self.__get_result()
  File "/usr/local/lib/python3.10/concurrent/futures/", line 403, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.10/site-packages/prefect/server/database/migrations/", line 167, in apply_migrations
    async with engine.connect() as connection:
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/ext/asyncio/", line 127, in __aenter__
    return await self.start(is_ctxmanager=True)  # type: ignore
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/ext/asyncio/", line 268, in start
    await greenlet_spawn(self.sync_engine.connect)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/", line 190, in greenlet_spawn
    result = context.throw(*sys.exc_info())
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/", line 3264, in connect
    return self._connection_cls(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/", line 145, in __init__
    self._dbapi_connection = engine.raw_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/", line 3288, in raw_connection
    return self.pool.connect()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/", line 452, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/", line 1267, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/", line 716, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/", line 169, in _do_get
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/", line 147, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/", line 167, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/", line 393, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/", line 678, in __init__
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/", line 902, in __connect
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/", line 147, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/", line 898, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/", line 637, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/", line 615, in connect
    return self.loaded_dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/dialects/postgresql/", line 917, in connect
    await_only(creator_fn(*arg, **kw)),
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/", line 125, in await_only
    return current.driver.switch(awaitable)  # type: ignore[no-any-return]
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/", line 185, in greenlet_spawn
    value = await result
  File "/usr/local/lib/python3.10/site-packages/asyncpg/", line 2114, in connect
    return await connect_utils._connect(
  File "/usr/local/lib/python3.10/site-packages/asyncpg/", line 1011, in _connect
    raise last_error or exceptions.TargetServerAttributeNotMatched(
  File "/usr/local/lib/python3.10/site-packages/asyncpg/", line 982, in _connect
    conn = await _connect_addr(
  File "/usr/local/lib/python3.10/site-packages/asyncpg/", line 808, in _connect_addr
    return await __connect_addr(params, timeout, True, *args)
  File "/usr/local/lib/python3.10/site-packages/asyncpg/", line 860, in __connect_addr
    tr, pr = await compat.wait_for(connector, timeout=timeout)
  File "/usr/local/lib/python3.10/site-packages/asyncpg/", line 60, in wait_for
    return await asyncio.wait_for(fut, timeout)
  File "/usr/local/lib/python3.10/asyncio/", line 458, in wait_for
    raise exceptions.TimeoutError() from exc