Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk13 min

How to Connect a Laravel App to MariaDB on Dokku

Install the Dokku MariaDB plugin, create and link a service, align Laravel’s database configuration with the generated DATABASE_URL, migrate from the app container, and verify the service without exposing it publicly.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable Dokku workflow is: install the official MariaDB plugin on the Dokku host, create a MariaDB service, link that service to your Laravel app, confirm that Laravel reads the generated connection URL, deploy, and run migrations from the app container. Linking keeps MariaDB on Dokku’s private Docker network and supplies the app with an internal DATABASE_URL.

What the connection looks like

Dokku services are separate containers. Your Laravel web container does not connect to a database on localhost; it connects to the MariaDB service over Dokku’s internal Docker network. The plugin creates the service, stores its credentials, and exposes a connection URL when you link it to an application.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A typical generated value has this shape:

mysql://<user>:<password>@dokku-mariadb-appdb:3306/appdb

The hostname is intended for containers attached to Dokku’s network. It is not a public DNS name for your laptop or the wider internet. You normally do not need to expose MariaDB publicly just to let Laravel use it.

Prerequisites and version checks

  • A running Dokku host with administrative access.
  • Docker meeting the plugin’s documented minimum of 1.8.x or newer.
  • Dokku 0.19.x or newer, as stated in the plugin documentation.
  • A Laravel application already configured as a Dokku app, with a web process that honors Dokku’s PORT environment variable.
  • A decision about the service name. Choose a stable name such as appdb; changing names later means changing the link and application configuration.

The plugin documentation is maintained at https://github.com/dokku/dokku-mariadb.git. It currently reports MariaDB 12.2.2 as the default image version. Treat that as a value to review before production: check the image and compatibility requirements for the release you intend to run rather than assuming every application should use the newest default.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

1. Install the Dokku MariaDB plugin

Run the installation on the Dokku host, not inside the Laravel container:

sudo dokku plugin:install https://github.com/dokku/dokku-mariadb.git --name mariadb

The --name mariadb option gives the plugin the command namespace used in the remaining examples. After installation, Dokku should recognize commands such as dokku mariadb:create, dokku mariadb:link, and dokku mariadb:info.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If the install fails, first check that the host can reach GitHub, that the command is being run with the required privileges, and that the Dokku and Docker versions satisfy the plugin’s documented requirements. Do not create a service until the plugin installation completes successfully; otherwise later failures can look like database or Laravel problems when the service commands are simply unavailable.

2. Create a MariaDB service

Create the service before attempting to link it:

dokku mariadb:create appdb

appdb is the service name in this example. The plugin creates the database container, initializes its credentials, and records the service so Dokku can manage links and lifecycle operations. Use a name that communicates ownership and will remain meaningful if you deploy more applications to the same host.

Do not confuse the service name with the Laravel application name. If your Dokku app is called my-laravel-app, the two resources are still distinct:

Resource Example name Purpose
MariaDB service appdb Runs MariaDB and owns the database credentials.
Dokku application my-laravel-app Runs Laravel’s web and worker processes.

The plugin’s current documentation reports MariaDB 12.2.2 as its default image version. Before a production deployment, verify that your Laravel version, SQL modes, extensions, and migration set are compatible with the image selected by the plugin. Pin or change the image only according to the plugin’s documented procedure; do not treat the reported default as a guarantee that it will remain unchanged.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Link the service to the Laravel app

Linking is the operation that gives the app its connection information:

dokku mariadb:link appdb my-laravel-app

Dokku normally restarts the app after a link. The plugin sets DATABASE_URL to an internal URI similar to:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
mysql://<user>:<password>@dokku-mariadb-appdb:3306/appdb

The exact username, password, and generated hostname are controlled by the service, so copy the value from Dokku rather than constructing credentials by hand. The hostname beginning with dokku-mariadb- is for Docker-network connectivity. It should be used by the Laravel container, not entered into a desktop SQL client outside the host.

What linking changes

The link is more than a note associating two names. It injects service connection data into the app environment and, by default, causes a restart so new processes can read that environment. Plan for that restart during deployment. If the app has several processes, each process that opens a database connection must receive the same linked environment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not copy the generated password into source control or hard-code the internal hostname in application files. The service owns those values; if the service is recreated, the generated credentials or endpoint can change. Let Dokku provide the link variables and make Laravel consume them at runtime.

Multiple database services

An application can have more than one linked service. The first or promoted service supplies the primary DATABASE_URL. Additional links can receive an alternate variable named in the form DOKKU_DATABASE_<ALIAS>_URL. This lets an application use separate databases for a secondary connection, reporting, or a migration transition, provided the Laravel configuration explicitly maps that variable to a named connection.

The plugin also provides mariadb:promote to make another linked service the primary one. Promotion changes which service is represented by DATABASE_URL; verify the resulting environment and run an application-level connection check before directing traffic to the new primary.

4. Make Laravel read the variable Dokku provides

Laravel’s database settings live in config/database.php. Laravel documentation supports MariaDB 10.3 and newer and documents URL-based configuration when a URL value or DB_URL is present. The important point is not to assume that every Laravel application reads the same variable: inspect the deployed application’s configuration and identify whether its connection definition consumes DATABASE_URL, DB_URL, or individual variables.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When the application supports a database URL

If the connection definition reads a URL, leave the generated DATABASE_URL available to the app and ensure the URL parser is enabled by the configuration used in your deployment. The URL contains the driver, credentials, internal host, port, and database name in one value. Avoid replacing it with a public address; the internal hostname is the intended path between the two containers.

When the application expects separate variables

Some Laravel projects define their connection using separate environment variables such as:

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
  • DB_HOST
  • DB_PORT
  • DB_DATABASE
  • DB_USERNAME
  • DB_PASSWORD

In that case, the presence of DATABASE_URL alone does not prove that Laravel will use it. Map the service credentials and endpoint to the variables that config/database.php actually reads. Use the host and port from the linked service’s generated URL, keep the database name consistent with the service, and do not invent a second set of credentials. If you change the configuration source, redeploy so the application container receives the final values.

Nonstandard URL schemes

If the application requires a URL scheme other than the plugin’s normal MySQL-compatible form, the plugin documents the MARIADB_DATABASE_SCHEME setting. Its documented procedure is to unlink the service before changing the scheme and then link it again. Follow that order; editing the scheme while leaving the old link in place can leave the application with stale connection metadata.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Deploy Laravel and run migrations

After the service is linked and the Laravel configuration matches the supplied variable, push or redeploy the application. Linking supplies the database environment, but your release still has to boot correctly as a Dokku web process. In particular, the web server must listen on the PORT value Dokku supplies instead of assuming a fixed port.

Run schema migrations from the application container, where the internal service hostname resolves:

dokku run my-laravel-app php artisan migrate --force

The --force flag is appropriate for a non-interactive deployment command. Run it only after confirming that the linked service is available and that the application is pointing at the intended database. A migration executed against the wrong service can succeed while changing the wrong schema, so verify the app and service names in the command before pressing Enter.

Pre-migration checks

Before applying a production migration, confirm the service name, app name, selected primary link, and database name. Check that the service reports healthy status and that Laravel’s effective configuration uses the linked host rather than a leftover staging or local value. If more than one service is linked, determine whether the app is reading DATABASE_URL or an alias variable. Run the migration from the Dokku app container, not from a shell on your personal computer, because the internal service hostname is normally resolvable only on the Dokku Docker network.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

After the migration, exercise a route, queue job, or health check that performs a real database read and write appropriate to your application. This catches cases where the migration command used one connection while a web or worker process uses another.

Recommended deployment order

  1. Install the plugin and verify that its commands are available.
  2. Create the MariaDB service with its permanent name.
  3. Link the service to the exact Dokku app name.
  4. Inspect Laravel’s config/database.php and align its URL or variable names.
  5. Deploy or redeploy the app so the container receives the link environment.
  6. Run php artisan migrate --force through dokku run.
  7. Exercise a database-backed route or job and inspect logs before declaring the release healthy.

6. Verify the service and diagnose failures

Start with Dokku’s service-level information:

dokku mariadb:info appdb

This command is useful for confirming that the service exists, checking its status, and inspecting the DSN that Dokku generated. Compare the service name, host, port, and database name shown there with what Laravel is configured to read.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

For startup, authentication, or initialization errors, inspect the service logs:

dokku mariadb:logs appdb

Then inspect the app’s environment and Laravel logs. The following symptoms usually point to different layers:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Symptom Likely layer What to check
“Command not found” for dokku mariadb:* Plugin installation Recheck the plugin install, host privileges, and version requirements.
Connection refused or an unavailable service MariaDB container Run dokku mariadb:info appdb and dokku mariadb:logs appdb.
Authentication failure Credentials or stale configuration Compare the generated DSN with the values Laravel actually reads; redeploy after correcting them.
Unknown host Network location Confirm the app is using the internal service hostname from the link, not a laptop-only or public hostname.
Laravel reports no configured connection Application configuration Inspect config/database.php and determine whether it consumes DATABASE_URL, DB_URL, or separate DB_* variables.
Web process fails after deployment Dokku process contract Ensure the web server honors Dokku’s PORT environment variable.

A successful link does not guarantee that Laravel is using it. Dokku can set DATABASE_URL while a project continues reading only DB_HOST and related variables. That mismatch is one of the most common reasons a service appears healthy while the framework reports a missing or unreachable database.

7. Keep MariaDB private unless external access is required

The generated service hostname and network are designed for internal Docker connectivity. Do not run mariadb:expose merely to connect Laravel to the database; exposing the service is a separate operation intended for cases where an external client genuinely needs public-interface access.

Keeping the service private reduces the number of reachable interfaces and avoids turning database credentials into an internet-facing attack surface. If an administrator or migration tool outside the Dokku host must connect, document that requirement separately, restrict access at the network boundary, and treat the exposure as an exception rather than part of the normal Laravel deployment.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

8. Backups, exports, and recovery

A self-hosted service is not production-ready merely because migrations succeed. The plugin provides mariadb:backup, mariadb:export, and mariadb:import commands. Establish a schedule, store backup artifacts somewhere other than the database container, and test restoring into a disposable service before relying on the procedure.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What a usable recovery procedure should answer

  • Where backup files are written and how they are protected.
  • How often backups run and how many historical copies are retained.
  • Which operator can run export and import commands.
  • How to create a replacement service and reconnect the Laravel app if the original service is lost.
  • How to validate restored tables and application behavior before switching production traffic.

Exports and imports are operational controls, not substitutes for testing. A file that was created successfully can still be unusable if credentials, character sets, permissions, or the target MariaDB version differ from the production service.

Linked Dokku MariaDB versus an external managed service

Dokku’s linked service is a self-hosted choice. An external managed MariaDB service changes who operates the database and where the network path runs. The primary decision factors are operational rather than Laravel-specific:

Decision factor Linked Dokku service External managed MariaDB
Network location Same Dokku host or Docker network; normally a short internal path. Separate provider network; latency and firewall rules must be planned.
Backups and upgrades You schedule, monitor, and test them using Dokku/plugin operations. The provider may operate them, but scope and guarantees depend on its plan.
Recovery controls Plugin backup, export, and import commands are directly available. Recovery tools and retention are provider-specific.
Cost No price is established by Dokku’s cited documentation; host and storage costs are your responsibility. Pricing and service levels vary by provider and are not established here.
Version control You choose when to review and change the plugin’s MariaDB image. The provider controls available versions and upgrade windows.
Operational responsibility You own patching, capacity, monitoring, backups, and restoration. The provider handles some infrastructure work, while you still own Laravel credentials, schema changes, and application compatibility.

For a small Dokku deployment that values a private network and direct control, linking the plugin service is straightforward. Choose an external service when its managed recovery, geographic separation, or operational guarantees justify the additional network and provider dependencies.

Final connection checklist

  • The MariaDB plugin is installed on the Dokku host.
  • The service was created with dokku mariadb:create <service> before linking.
  • The app is linked with dokku mariadb:link <service> <app>.
  • DATABASE_URL or the alternate linked variable is the variable Laravel’s configuration actually reads.
  • The app uses the internal service hostname and does not require MariaDB to be exposed publicly.
  • The web process honors PORT.
  • Migrations run from the app container and target the intended service.
  • dokku mariadb:info and dokku mariadb:logs show a healthy service.
  • Backup, export, import, and restore procedures have been tested.

Frequently Asked Questions

Why is Laravel not reading Dokku’s DATABASE_URL?

Dokku can set DATABASE_URL while the project’s config/database.php reads only DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, and DB_PASSWORD. Inspect the connection definition and either enable its URL-based configuration or map the linked service values to the variables it actually consumes. Redeploy after changing the configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do I need to expose MariaDB for Laravel to connect?

No. The linked hostname is designed for containers on Dokku’s internal Docker network. Use mariadb:expose only when an external client genuinely requires public-interface access. Exposing the service just to make Laravel connect adds unnecessary network exposure.

What is the correct order: create, link, or migrate?

Create the service first with dokku mariadb:create, link it with dokku mariadb:link, align Laravel’s configuration, deploy or redeploy the app, and then run php artisan migrate --force through dokku run. This order ensures the migration runs from a container that can resolve the internal service hostname.

Can one Laravel app use two MariaDB services?

Yes. The primary link provides DATABASE_URL; additional links can receive a variable such as DOKKU_DATABASE_ALIAS_URL. Define a separate Laravel connection that reads the alternate variable. The plugin’s mariadb:promote command can make another linked service the primary URL, so verify the environment before switching traffic.

What should I check when the service refuses connections?

Run dokku mariadb:info appdb to confirm that the service exists and is running, then inspect dokku mariadb:logs appdb for startup or authentication errors. Compare the reported DSN with Laravel’s effective host, port, database, and credentials. Also confirm that the app is using the internal Dokku hostname rather than a public or laptop-only address.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which MariaDB version should I use?

The plugin documentation currently reports MariaDB 12.2.2 as its default image version, while Laravel documents MariaDB 10.3 and newer support. Review the selected image and verify compatibility with your Laravel release, extensions, SQL modes, and migrations before production. Do not assume the plugin’s current default will remain unchanged.

Why does linking restart my Dokku app?

The link operation injects the service connection environment and normally restarts the app so new web and worker processes receive it. Schedule the link accordingly and verify every process that opens database connections after the restart. A successful restart still does not prove Laravel is reading the supplied variable.

Are Dokku backups enough for production?

The plugin supplies backup, export, and import commands, but you still need a schedule, protected storage outside the database container, retention rules, and a tested restore procedure. Restore into a disposable service and validate tables and application behavior. A successfully created export is not proof that recovery will work against a different version or credential set.

The Bottom Line

Install dokku-mariadb, create the service before linking it, and link it to the exact Laravel app name. Make config/database.php consume the generated URL or explicitly mapped variables, migrate from the app container, and verify with Dokku’s info and logs commands. Keep the service private and test backup and restore operations before relying on the deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.