Cannot start pnpm run dokploy:setup
To Reproduce
I have followed all steps from the contributing file. However if i run pnpm run dokploy:setup It gives me the following issues:
pnpm run dokploy:setup
> dokploy@ dokploy:setup /mnt/dev-projects/dokploy/dokploy
> pnpm --filter=dokploy run setup
> [email protected] setup /mnt/dev-projects/dokploy/dokploy/apps/dokploy
> tsx -r dotenv/config setup.ts && sleep 5 && pnpm run migration:run
Default middlewares already exists
2025-07-25T20:01:03.406Z WARN [Better Auth]: Social provider github is missing clientId or clientSecret
2025-07-25T20:01:03.408Z WARN [Better Auth]: Social provider google is missing clientId or clientSecret
Swarm is already initilized
Network is already initilized
Main config already exists
Default traefik config already exists
No existing service to remove
No existing container to remove
Failed to initialize Traefik: Error: (HTTP code 404) no such container - No such image: traefik:v3.1.2
at /mnt/dev-projects/dokploy/dokploy/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:383:17
at getCause (/mnt/dev-projects/dokploy/dokploy/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:418:7)
at Modem.buildPayload (/mnt/dev-projects/dokploy/dokploy/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:379:5)
at IncomingMessage.<anonymous> (/mnt/dev-projects/dokploy/dokploy/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:347:16)
at IncomingMessage.emit (node:events:531:35)
at endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
reason: 'no such container',
statusCode: 404,
json: { message: 'No such image: traefik:v3.1.2' }
}
Error in dokploy setup Error: (HTTP code 404) no such container - No such image: traefik:v3.1.2
at /mnt/dev-projects/dokploy/dokploy/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:383:17
at getCause (/mnt/dev-projects/dokploy/dokploy/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:418:7)
at Modem.buildPayload (/mnt/dev-projects/dokploy/dokploy/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:379:5)
at IncomingMessage.<anonymous> (/mnt/dev-projects/dokploy/dokploy/node_modules/.pnpm/[email protected]/node_modules/docker-modem/lib/modem.js:347:16)
at IncomingMessage.emit (node:events:531:35)
at endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
reason: 'no such container',
statusCode: 404,
json: { message: 'No such image: traefik:v3.1.2' }
}
> [email protected] migration:run /mnt/dev-projects/dokploy/dokploy/apps/dokploy
> tsx -r dotenv/config migration.ts
Migration failed Error: connect ECONNREFUSED 127.0.0.1:5432
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1607:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5432
}
Im not sure how to proceed, i did saw https://github.com/Dokploy/dokploy/issues/2029 but it should have been fixed right? (i started clean with the clone and everything, the only step that i messed up was selecting the right node version)
Current vs. Expected behavior
I expected the commands to run smoothly and create the required docker containers. Right now there are 0 containers added to docker.
Provide environment information
OS: Debian
Which area(s) are affected? (Select all that apply)
Local Development
Are you deploying the applications where Dokploy is installed or on a remote server?
Same server where Dokploy is installed
Additional context
No response
Will you send a PR to fix it?
No
In fact it was supposed to now automatically pull the Traefik image required during the setup. Make sure you have a fresh clean clone of the canary branch. However, if you're starting from a clean clone and still facing this, it's possible that the fix hasn't fully resolved it yet.
For now, you can try manually pulling the image to verify availability:
docker pull traefik:v3.1.2
This will prevent this error and make sure the image already available on your system when running the setup script.
@jhon2c Thank you for your anwer! Its not working eventho i tried to pull it manually (also not on the canary branch). Any other hints? Im on LinuxMint. The docker command can be executed without sudo and the image also appears if i run docker image ls.
@Attacler can you run this commands locally?
docker pull traefik:v3.1.2
docker pull redis:7
docker pull postgres:16
And then run again the setup script?
I will close this issue for inactivity, feel free to reopen if you still have the same issue
sudo pnpm run dokploy:setup
> dokploy@ dokploy:setup /home/horsley/dokploy
> pnpm --filter=dokploy run setup
> [email protected] setup /home/horsley/dokploy/apps/dokploy
> tsx -r dotenv/config setup.ts && sleep 5 && pnpm run migration:run
⚠️ [DEPRECATED DATABASE CONFIG]
You are using the legacy hardcoded database credentials.
This mode WILL BE REMOVED in a future release.
Please migrate to Docker Secrets using POSTGRES_PASSWORD_FILE.
Please execute this command in your server: curl -sSL https://dokploy.com/security/0.26.6.sh | bash
Default middlewares already exists
2026-02-07T06:27:00.973Z WARN [Better Auth]: [better-auth] Base URL could not be determined. Please set a valid base URL using the baseURL config option or the BETTER_AUTH_BASE_URL environment variable. Without this, callbacks and redirects may not work correctly.
2026-02-07T06:27:00.975Z WARN [Better Auth]: Social provider github is missing clientId or clientSecret
2026-02-07T06:27:00.975Z WARN [Better Auth]: Social provider google is missing clientId or clientSecret
node:internal/process/promises:391
triggerUncaughtException(err, true /* fromPromise */);
^
AggregateError [ECONNREFUSED]:
at internalConnectMultiple (node:net:1123:18)
at afterConnectMultiple (node:net:1683:7) {
code: 'ECONNREFUSED',
[errors]: [
Error: connect ECONNREFUSED ::1:5432
at createConnectionError (node:net:1646:14)
at afterConnectMultiple (node:net:1676:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 5432
},
Error: connect ECONNREFUSED 127.0.0.1:5432
at createConnectionError (node:net:1646:14)
at afterConnectMultiple (node:net:1676:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5432
}
]
}
Node.js v20.19.4
@Siumauricio I meet the same problem too, I've check the logic in setup.ts it seems that it fails silently in many steps. Above logs was about connect to postgres but related service was not created at all, including dokploy-network and so on. It's quite weird those steps like setup network/swarms should print console log either “already initilized” or newly initilized. But there was none of these lines. I will do some investigation
Bug Description
Running pnpm run dokploy:setup fails with ECONNREFUSED error when the PostgreSQL database container doesn't exist yet. This is a chicken-and-egg problem: the setup script is supposed to create the database, but it fails before creating it because it tries to connect to the database during module import.
Steps to Reproduce
- Clone the repository and follow the CONTRIBUTING.md setup instructions
- Ensure no
dokploy-postgresservice exists:docker service rm dokploy-postgres - Run
pnpm run dokploy:setup
Expected Behavior
The setup script should successfully create the PostgreSQL and Redis services, then run migrations.
Actual Behavior
The script fails with:
Default middlewares already exists
2026-02-07T07:19:15.422Z WARN [Better Auth]: [better-auth] Base URL could not be determined...
2026-02-07T07:19:15.424Z WARN [Better Auth]: Social provider github is missing clientId or clientSecret
AggregateError [ECONNREFUSED]:
at internalConnectMultiple (node:net:1122:18)
at afterConnectMultiple (node:net:1689:7) {
code: 'ECONNREFUSED',
[errors]: [
Error: connect ECONNREFUSED ::1:5432
Error: connect ECONNREFUSED 127.0.0.1:5432
]
}
Root Cause Analysis
The issue is in apps/dokploy/setup.ts:
import { execAsync } from "@dokploy/server";
When importing from @dokploy/server, the entire package is loaded, including packages/server/src/lib/auth.ts. This module initializes betterAuth() at the module level (not inside a function):
// packages/server/src/lib/auth.ts line 21-22
const { handler, api } = betterAuth({
database: drizzleAdapter(db, { ... }), // This connects to DB immediately!
This causes a database connection attempt before the setup script has a chance to run initializePostgres().
Proposed Solution
Replace the import from @dokploy/server with Node.js native utilities in setup.ts:
import { exit } from "node:process";
-import { execAsync } from "@dokploy/server";
+import { exec } from "node:child_process";
+import { promisify } from "node:util";
+
+const execAsync = promisify(exec);
This avoids loading the @dokploy/server main entry point, which prevents the auth.ts module from being evaluated during setup.
Alternative Long-term Solutions
- Lazy initialization: Refactor
lib/auth.tsto use lazy initialization forbetterAuth(), only connecting when first accessed - Separate exports: Add a
@dokploy/server/utilsexport path that doesn't include the auth module - Conditional exports: Use package.json
exportsto provide a setup-safe subset of utilities
Environment
- Node.js: v20.19.3
- pnpm: 9.12.0
- OS: macOS (via OrbStack/Ubuntu)