A customer paid for a downloadable product in your WooCommerce store and cannot get the file. The link is missing from the email, or it opens a page that says “Invalid download link”, or the file arrives empty. This page is for the store owner or developer who has to answer that customer. WooCommerce runs every download click through the same checks, in the same order, and stops at the first one that fails. The message on screen tells you which one. Three commands then show you the order, the download permission and the file.
What you’ll accomplish
- Match the message your customer sees to the exact check that rejected the download.
- Read the order’s download permissions in the database: remaining downloads, expiry date and email.
- Restore access for one customer without changing the product for everyone.
- Confirm that the file is delivered whole, and that its real address stays private.
Prerequisites
- WooCommerce 6.5 or newer. The error messages quoted here are the ones in version 11.3.
- An administrator account, and shell access with WP-CLI (the
wpcommand). Run the commands from the site’s root directory as the user that owns the files. - The order number and the product ID. The examples use order
6184and product2953. For a variable product, use the ID of the variation that was bought.
How it works
A download link is the address of your home page with four values added to it. download_file is the product ID. order is the order key, a random string that starts with wc_order_. key is the ID of one file on the product. The fourth identifies the customer. Links in emails carry uid, a hash of the billing email, and links on the My account page carry email.
When the order reaches Processing or Completed, WooCommerce writes one row per file in the table woocommerce_downloadable_product_permissions. That row is the download permission. It stores the order key, the customer’s email, the downloads left (downloads_remaining) and the expiry date (access_expires).
On each click, WooCommerce reads the link and looks for the matching row. It then runs the checks in the order shown in the diagram. Two details are worth knowing before you start:
- The first two checks share one message. “Invalid download link.” means either that the file is not usable on the product, or that no permission row matches the link.
- The download is counted before the file is sent. If delivery fails, each retry still uses up one of the customer’s downloads.
An email prints a link only when the order status allows downloads and a permission row matches the billing email. The My account page also leaves out files that are disabled, used up or expired.
Step-by-step
-
Match the symptom to a check. Ask the customer for the exact words on the page:
What the customer sees Check that failed Go to No link in the email or on My account Order status, or no permission row Steps 2 and 3 Invalid download link. File on the product, or permission row Steps 3 and 4 Invalid order. Order status Step 2 Sorry, you have reached your download limit for this file Downloads left Step 5 Sorry, this download has expired Expiry date Step 5 You must be logged in to download files. Login rule Step 6 File not found, an empty file or a damaged file Delivery Step 7 -
Check the order status and the access setting. The first command prints the status, the billing email and whether permissions were created. The second prints the setting that decides when access starts:
wp eval '$o = wc_get_order( 6184 ); echo $o->get_status(), " ", $o->get_billing_email(), " ", var_export( $o->get_download_permissions_granted(), true ), PHP_EOL;' wp option get woocommerce_downloads_grant_access_after_paymentExample output:
completed dana.okafor@example.net true yesDownloads are allowed when the status is
completed. They are also allowed onprocessingwhen the setting isyes, which is the default. With any other status, such ason-holdorpending, no link is shown and an old link answers “Invalid order.” Confirm the payment, then move the order to Completed. See WooCommerce order statuses for what moves an order between them.If the setting is
no, customers wait until the order is Completed. WooCommerce completes a paid order by itself only when every product in it is both Virtual and Downloadable. An order with a product that is Downloadable only stays on Processing until you complete it. To give access at payment, go to WooCommerce → Settings → Products → Downloadable products and tick Grant access to downloadable products after payment. -
Read the permission rows. This lists what WooCommerce stored for the order:
wp db query "SELECT permission_id, product_id, download_id, user_email, user_id, downloads_remaining, access_expires, download_count FROM $(wp db prefix)woocommerce_downloadable_product_permissions WHERE order_id = 6184"Example output:
+---------------+------------+--------------------------------------+-------------------------+---------+---------------------+---------------------+----------------+ | permission_id | product_id | download_id | user_email | user_id | downloads_remaining | access_expires | download_count | +---------------+------------+--------------------------------------+-------------------------+---------+---------------------+---------------------+----------------+ | 913 | 2953 | 3f2a9c1e-7b64-4d0a-9e51-c8a2f61d0b37 | dana.okafor@example.net | 57 | 0 | 2026-11-09 00:00:00 | 3 | | 914 | 2953 | a81d5e02-93cf-4b7e-8f16-2e7c40b9d5aa | dana.okafor@example.net | 57 | 2 | 2026-11-09 00:00:00 | 1 | +---------------+------------+--------------------------------------+-------------------------+---------+---------------------+---------------------+----------------+Read it this way:
- No rows. The permissions were never created, or were removed. This happens when the product had no file, or was not marked Downloadable, on the day the order was paid. Step 2 still prints
truein that case, so WooCommerce will not try again by itself. Go to step 5 and regenerate. user_emaildiffers from the billing email in step 2. The link is checked against the billing email, so no row matches. Correct the billing email on the order if it is wrong, then regenerate in step 5.downloads_remainingis0. The limit is reached. An empty value means unlimited.access_expiresis before today. The access has expired.NULLmeans it never expires.
- No rows. The permissions were never created, or were removed. This happens when the product had no file, or was not marked Downloadable, on the day the order was paid. Step 2 still prints
-
Check the file on the product. This prints each file’s ID, whether WooCommerce accepts it, and its address:
wp eval 'foreach ( wc_get_product( 2953 )->get_downloads() as $id => $f ) { echo $id, " ", var_export( $f->get_enabled(), true ), " ", $f->get_file(), PHP_EOL; }'Example output:
3f2a9c1e-7b64-4d0a-9e51-c8a2f61d0b37 true https://shop.example.com/wp-content/uploads/woocommerce_uploads/2026/09/field-guide-k3x9wq.pdf a81d5e02-93cf-4b7e-8f16-2e7c40b9d5aa false https://files.example.org/packs/field-guide-audio.zipEach
download_idfrom step 3 must appear in this list withtrue. An ID that is missing means the file row was deleted from the product, and the old links died with it. Regenerate in step 5. A file markedfalseis disabled. WooCommerce disables a file when its address is not inside an approved download directory, or when a file given as a server path no longer exists. Approved download directories, added in WooCommerce 6.5, is the list of locations that product files may be served from. Read it:wp option get wc_downloads_approved_directories_mode wp db query "SELECT url_id, url, enabled FROM $(wp db prefix)wc_product_download_directories"Example output:
enabled +--------+------------------------------------------------------------------+---------+ | url_id | url | enabled | +--------+------------------------------------------------------------------+---------+ | 1 | file:///var/www/shop/wp-content/uploads/woocommerce_uploads/ | 1 | | 2 | https://shop.example.com/wp-content/uploads/woocommerce_uploads/ | 1 | | 3 | https://files.example.org/packs/ | 0 | +--------+------------------------------------------------------------------+---------+The first line is the mode. With
disabled, the list is not enforced and cannot be the cause. Here rule 3 covers the second file and is switched off. That happens, for example, when someone who is not an administrator adds a file from a new location. Go to WooCommerce → Settings → Products → Approved download directories, hover the rule and click Enable. If no rule covers the file’s address, click Add New and enter the folder’s URL. Run the first command of this step again. The file now printstrue, and existing links work again. -
Repair the permission. Open the order in WooCommerce → Orders. For a reached limit or an expired access, use the Downloadable product permissions box. Since WooCommerce 11.1 it is hidden by default, so tick it under Screen Options first. Raise Downloads remaining, or empty the field for unlimited. Set Access expires to a later date, or empty it for no expiry. Then click Update.
For missing or mismatched rows, choose Regenerate download permissions in the Order actions box and apply it. This deletes the order’s rows and their download history, then creates new rows from the product’s current files, limit and expiry. The expiry is counted from the order’s completion date when it has one. On an old order, the new permission can therefore be expired at once; extend it in the permissions box. Run step 3 again to confirm the new rows.
-
Check the login rule. Print the setting:
wp option get woocommerce_downloads_require_loginExample output:
yesWith
yes, a customer who bought with an account must be signed in to that account. Otherwise WooCommerce sends them to the My account page with the message “You must be logged in to download files.” Guest orders, whereuser_idis0in step 3, are not affected. If you test a customer’s link while signed in as yourself, you get “This is not your download link.” -
Test the delivery. Read how files are sent:
wp option get woocommerce_file_download_method wp option get woocommerce_downloads_redirect_fallback_allowedExample output:
xsendfile noA second option that WP-CLI reports as missing counts as
no. The method is one of three values:force(Force downloads, the default): PHP reads the file and sends it in pieces of 1 MB. The file’s real address stays hidden.xsendfile(X-Accel-Redirect/X-Sendfile): PHP checks the permission, then hands the transfer to the web server. On nginx it sends anX-Accel-Redirectheader. On Apache it sendsX-Sendfile, and only when PHP can see themod_xsendfilemodule. If WooCommerce finds no web server that supports this, it falls back to Force downloads and writes a warning in its log.redirect, shown as Redirect only (Insecure): the browser is sent to the file’s real address. Anyone who has that address can download the file without paying.
Now request the link the way a browser would. This uses one download from the customer’s limit:
URL=$(wp eval 'foreach ( wc_get_order( 6184 )->get_downloadable_items() as $d ) { echo $d["download_url"], PHP_EOL; }' | head -n 1) curl -s -o /tmp/download-test.bin -w '%{http_code} %{content_type} %{size_download}\n' "$URL"Example output:
200 application/pdf 4821337Compare the last number with the real file’s size on the server, which
wc -cprints in bytes. The same size and a200mean delivery works. Otherwise:- An empty
URLvariable. The order has no usable link. Go back to steps 2 to 4. 403or404andtext/html. The response is an error page. Rungrep -o 'wp-die-message">[^<]*' /tmp/download-test.binto print the WooCommerce message, then find it in the table in step 1.302. Either the login rule from step 6 applied, or the method isredirect.- The message is “File not found”. PHP could not open the file. The code is
404in WooCommerce 11.3 and403in earlier versions. For a file on your server, the address on the product points to a file that is gone. For a file hosted elsewhere, PHP must be allowed to open remote addresses, which is theallow_url_fopensetting. 404withxsendfile, and thegrepprints nothing. The error page comes from nginx, which could not find the path it was handed. Switch the method to Force downloads to confirm.200with a different size. The file was cut short or has extra bytes. See Troubleshooting.
Validate it works
Run the test from step 7 once more, then read the permission row again:
curl -s -o /tmp/download-test.bin -w '%{http_code} %{content_type} %{size_download}\n' "$URL"
wp db query "SELECT permission_id, downloads_remaining, access_expires, download_count FROM $(wp db prefix)woocommerce_downloadable_product_permissions WHERE order_id = 6184"
You are done when the first line shows 200 and the real file size, and download_count has gone up by one. Add one to Downloads remaining for each test you ran, so the customer gets their full count back. Then, in the Order actions box, choose Send order details to customer and apply it, so the customer receives a current link.
Troubleshooting
-
The file downloads but will not open, or is a few bytes too large. Another plugin or the theme may have printed text before the file. Count the warnings in the WooCommerce log folder:
grep -rhoE "could not be served using the [A-Za-z/ -]+ method|cannot be removed or cleaned|response had already started" "$(wp eval 'echo wp_upload_dir()["basedir"];')/wc-logs/" | sort | uniq -cExample output:
4 could not be served using the X-Accel-Redirect/X-Sendfile methodThe first text names a method that failed and was replaced by the next one. The second, logged from WooCommerce 11.3, means other code’s output was sent before the file: deactivate plugins one at a time on a staging copy until the size from step 7 matches. The third means the read failed partway, so the file arrived cut short.
-
Large files stop partway. With Force downloads, PHP stays busy for the whole transfer, and a server or proxy timeout can cut it. WooCommerce already removes PHP’s own time limit, so raising
max_execution_timerarely helps. Move to X-Accel-Redirect/X-Sendfile and let the web server send the file. -
The file opens for anyone who has its address. WooCommerce protects the
woocommerce_uploadsfolder with an.htaccessfile containingdeny from all. nginx ignores that file. Addlocation ~* /woocommerce_uploads/ { internal; }to theserverblock, before other regular-expression locations, as the WooCommerce nginx guide describes. A direct request then returns 404, andX-Accel-Redirectdownloads keep working. Files picked from the Media Library are stored outside that folder and stay public, so upload product files from the product screen. -
The customer’s browser shows the real file address. The method is
redirect, or the second option in step 7 isyesand a file hosted elsewhere could not be fetched. Set the method to Force downloads and turn off the last-resort redirect. -
The link works for you and fails for the customer. They may be using an older email. A changed billing email or a file row deleted from the product makes old links invalid. Send the order details again.
When this is the wrong approach
These checks cover the download system built into WooCommerce. A membership, subscription or licence plugin that delivers files applies its own access rules, so start with its documentation. Files hosted on a cloud storage service often need a direct download address to work with Force downloads. The WooCommerce guide to digital and downloadable products covers that case. If the order never left Pending payment, start with orders stuck on Pending payment.
Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.