Domains & Traefik
Fix domains that aren't working, 404 errors, Bad Gateway errors, and Traefik routing issues.
Applications Domain Not Working?
You see the deployment succeeded, and logs are running, but the domain isn't working? Here's what to check:
-
Correct Port Mapping: Ensure the domain is using the correct port for your application. For example, if you're using Next.js, the port should be
3000, or for Laravel, it should be8000. If you change the app port, update the domain to reflect that. -
Avoid Using
Portsin Advanced Settings: Generally, there's no need to use thePortsfeature unless you want to access your app viaIP:port. Leaving this feature enabled may interfere with your domain. -
Let's Encrypt Certificates: It's crucial to point the domain to your server's IP before adding it in Dokploy. If the domain is added first, the certificate won't be generated, and you may need to recreate the domain or restart Traefik.
-
Listen on 0.0.0.0, Not 127.0.0.1: If your app is bound to
127.0.0.1(which is common in Vite apps), switch it to0.0.0.0to allow external access.
Docker Compose Domain Not Working?
When adding a domain in your Docker Compose file, it's not necessary to expose the ports directly. Simply specify the port where your app is running. Exposing the ports can lead to conflicts with other applications or ports.
Example of what not to do:
services:
app:
image: dokploy/dokploy:latest
ports:
- 3000:3000Recommended approach:
services:
app:
image: dokploy/dokploy:latest
ports:
- 3000
- 80This is only valid for Docker Compose not for Docker Stack.
When using Docker Stack, the ports are exposed automatically, so you don't need to specify them explicitly.
Example of what not to do:
services:
app:
image: dokploy/dokploy:latest
ports:
- 3000Recommended approach:
services:
app:
image: dokploy/dokploy:latest
expose:
- 3000Then, when creating the domain in Dokploy, specify the service name and port, like this:
domain: my-app.com
serviceName: app
port: 3000- Another reason of the domains are not working it may be because the healthchecks you've defined are not working, so this will cause the domains never work, so you have two options:
- Remove the healthcheck from the service
- Make sure the healthcheck is working
Templates and Compose Services Returning 404
If you're experiencing 404 errors when accessing services created from templates (like Docker Registry, Stalwart, Uptime Kuma, etc.) or Docker Compose services, this is usually related to how Traefik handles routing for different service types.
Understanding the Difference
Dokploy uses two different methods for configuring Traefik routing:
-
Applications (Nixpacks, Dockerfile, Buildpacks): Use the Traefik file system for routing configuration
- Domain changes are applied automatically
- No need to redeploy after updating domains
- Configuration files are created in Traefik's dynamic configuration directory
-
Templates and Compose Services: Use Traefik labels for routing configuration
- Require redeployment after any domain changes
- Labels are read from Docker container metadata
- Learn more about Traefik labels in the official documentation
Solution
When working with Templates or Compose services:
- Configure your domain in the Domains section of your service
- Redeploy the service - This is crucial! The domain changes won't take effect until you redeploy
- Wait for the deployment to complete
- Your service should now be accessible via the configured domain
Key Tip: Every time you add, modify, or remove a domain from a Template or Compose service, you must redeploy for the changes to take effect.
Getting "Bad Gateway Error" When Accessing Your Application Domain
If you're encountering a Bad Gateway Error when accessing your application through its domain, this typically indicates one of several common configuration issues:
Common Causes
- Port Mismatch: The configured port might be incorrect
- Listen Address Configuration: The service might be listening only on
127.0.0.1instead of0.0.0.0
Common Solution for Modern JavaScript Frameworks
This issue frequently occurs with modern JavaScript frameworks like Vite, Astro, or Vue.js applications. By default, these frameworks often listen only on localhost (127.0.0.1).
To resolve this, you need to configure your application to listen on all available network interfaces (0.0.0.0).
Example Configuration for Vite
Here's how to properly configure a Vite application:
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
preview: {
port: 3000,
host: true, // This enables listening on all network interfaces
},
server: { // Also add this for development server
host: true, // This enables listening on all network interfaces
port: 3000
}
});Framework-Specific Notes
- Vite Apps: Use the configuration above
- Astro: Similar configuration in
astro.config.mjs - Vue.js: Configure in
vite.config.jsif using Vite - Other Frameworks: Check your framework's documentation for network interface configuration
Remember to deploy again your application after making these changes for them to take effect.
Use of closed network when restarting Traefik
If you see this error in the logs of Traefik, it means that the network is being closed, this is the normal behavior when restarting Traefik.
05/23/25, 12:21:12 PM info 2025-05-23T09:21:12Z ERR: error="accept tcp [::]:443: use of closed network connection" entryPointName=websecure
05/23/25, 12:21:12 PM info 2025-05-23T09:21:12Z ERR: error="accept tcp [::]:9000: use of closed network connection" entryPointName=traefik
05/23/25, 12:21:12 PM info 2025-05-23T09:21:12Z ERR: error="accept tcp [::]:80: use of closed network connection" entryPointName=web
05/23/25, 12:21:12 PM info 2025-05-23T09:21:12Z ERR: error="close tcp [::]:9000: use of closed network connection" entryPointName=traefik
05/23/25, 12:21:12 PM info 2025-05-23T09:21:12Z ERR: error="close tcp [::]:443: use of closed network connection" entryPointName=websecure
05/23/25, 12:21:12 PM info 2025-05-23T09:21:12Z ERR: error="close tcp [::]:80: use of closed network connection" entryPointName=web