Troubleshooting the OpenEMR C-CDA service

How to diagnose and fix C-CDA generation failures in a self-hosted OpenEMR, covering Node.js version limits, port 6661 conflicts, package reinstalls after upgrades, Apache rewrite settings and export testing.

On this page

Why OpenEMR C-CDA generation fails and when to troubleshoot it

If C-CDA exports stopped generating, start with the installed OpenEMR version, the host runtime and the web server configuration, because the C-CDA service depends on all three. Clinics usually notice the problem when a clinical summary export or a referral document fails, and it often begins right after an upgrade, a move to new hosting or a rebuilt server. The C-CDA service is part of the interoperability work OpenEMR groups with its FHIR API, SMART on FHIR and bulk export features. Those features sit in the same application but are exposed through different paths, so a failure in one does not prove the others are broken, and a healthy FHIR API does not confirm that document generation works.

OpenEMR's recent releases require PHP 8.3 or later and run on a MySQL- or MariaDB-compatible database, and the project offers Docker deployment options. Any change to those layers, or to the server that runs the service alongside OpenEMR, can break document generation even when the login page loads normally. Before you change anything, record the exact OpenEMR version from the OpenEMR releases page, then confirm the service components, runtime versions, ports and commands that apply to that version in the OpenEMR documentation. The names and settings in this guide are not a substitute for that check, because they vary by release and by deployment method.

Plan a troubleshooting session when exports fail after a change you can name, when a support ticket shows repeated generation errors, or when a release upgrade is being staged and the export path has not been tested on the target version. Treat the work as a controlled investigation: capture the failing request, the error text, the logs and the configuration before you alter anything, and keep a rollback point. Decide in advance who may approve a configuration change, who checks whether the exported document still meets the receiving party's requirements, and whether any patient data appears in logs you collect. Those decisions matter as much as the fix, because a quick change to the wrong setting can leave a clinic exporting documents it cannot later verify. If the cause is unclear after a first pass, or the server is shared with other services, bring in an engineer who can rebuild the environment rather than patching it in place.

Common causes of C-CDA failures in a self-hosted OpenEMR

C-CDA generation failures in a self-hosted OpenEMR usually trace back to the service layer around the PHP application rather than the clinical data itself. The five categories below cover the runtime, the local network, the upgrade process, the web server and the file system, and each one has a first check you can run before changing anything.

Node.js runtime version limits

The C-CDA service runs on Node.js, so a runtime that is too old or too new for the installed package set can stop document generation without a clear error in the OpenEMR interface. Users typically see an export that spins, returns an empty result or fails only for some document types. First, check the Node.js version on the server that hosts the service against the version the OpenEMR release notes and the service's own documentation specify, and confirm which binary the web user actually resolves on its path.

OpenEMR releases

Port 6661 conflicts

The C-CDA service listens on a local port, and if another process already holds that port, the service fails to start or the OpenEMR side cannot reach it. Users see generation requests that time out after a host reboot or after another service is deployed on the same machine. First, check which process holds the port with a socket listing tool, stop or move the conflicting process, and confirm the service starts cleanly from its own log before retesting exports.

Missing or stale packages after upgrades

An OpenEMR upgrade can replace application files while leaving the service's installed packages out of step with the new release. The symptom is usually a module-not-found or version mismatch error the first time a document is generated after the upgrade. First, compare the package state in the service directory with the version of the release you deployed, then reinstall the packages from the release's own instructions rather than copying files from an older install.

Apache rewrite configuration

The C-CDA endpoints depend on URL rewriting in the Apache configuration, and a rewrite rule that was lost during a rebuild or a hardening change causes requests to return a 404 or to reach the wrong handler. Hardening guidance that restricts the web server to HTTPS and limits open ports can also block the internal path the service expects. First, confirm the rewrite module is enabled and that the virtual host for the OpenEMR site still includes the rules shipped with the release, then review the access log for the failing request path.

Securing OpenEMR guide

File and permission issues

Generated documents are written to and read from the OpenEMR site directories, so the web server user needs correct read and write access to those paths. A permission change during a restore, a migration or a hardening pass can make generation fail silently while the rest of the chart works normally. First, check ownership and permissions on the site documents path and the service's working directory for the web server user, and confirm that direct web access to the documents directory is blocked while the application can still write to it.

Which fix fits which symptom

This table pairs each C-CDA symptom with the cause named for it, the check that confirms it and the fix. Read the row that matches what you see, run the check first, and confirm any version-specific value against the OpenEMR release you have installed before changing anything.

SymptomLikely causeCheck that confirms itFix
C-CDA generation fails with an errorNode.js runtime outside the range the C-CDA service supports for your releaseCompare the installed Node.js version with the requirement listed for your OpenEMR versionInstall the supported Node.js version, restart the service and retest one export
No response on the C-CDA service portAnother process already holds port 6661List listeners on port 6661 and identify the process that owns itStop or move the conflicting process, or change the service port and update the matching OpenEMR setting
Exports worked before an upgrade and fail after itService packages were not reinstalled from the upgraded codeCompare the package versions in the service directory with the release you upgraded toReinstall the service packages from the upgraded code, restart the service and retest
Routes return 404 or the browser loops on redirectsApache rewrite settings missing or changed for the C-CDA service pathRead the Apache error log and request the route with curl to see the status code and redirect targetRestore the rewrite rules documented for your release, enable the required modules, reload Apache and retest

Step-by-step diagnosis and recovery sequence

This sequence moves from the cheapest checks to the most invasive ones, so the team can find the fault in the C-CDA service without changing things that are already working. Each step produces a result that decides whether the next step is needed.

  1. Confirm the OpenEMR version and PHP version

    Start by recording the installed OpenEMR version and the PHP version the web server actually runs, since the PHP binary used by Apache or PHP-FPM can differ from the command line default. Recent OpenEMR releases require PHP 8.3 or later, so an older PHP build is a likely cause before anything else is examined. Confirm the version in the admin interface or the installed files, and confirm PHP from the same runtime that serves the site. The step is done when both versions are written down and PHP is 8.3 or later.

  2. Check the Node.js runtime used by the service

    The C-CDA generation service runs on Node.js, so check which Node.js binary and version the service account resolves, not only the one in an interactive shell. Compare the result against the version your OpenEMR release documentation or the project repository states for that release, and confirm the path the service uses. Ask your OpenEMR support provider or the project documentation to confirm the supported Node.js range for your exact release before changing anything. The step is done when the runtime version is recorded and matches the supported range, or a mismatch is documented for correction.

  3. Confirm nothing else holds port 6661

    Check whether port 6661 is already bound by another process, such as a leftover Node.js instance, a container or a second OpenEMR copy on the same host. List listening sockets on the server and identify the owning process for port 6661. If the C-CDA service fails to start because the port is taken, stop the conflicting process only after confirming what it is and who uses it. The step is done when the port is either free or assigned to the C-CDA service alone, with the owner recorded.

  4. Reinstall packages after an upgrade

    If the failure began after an OpenEMR upgrade, the Node.js package dependencies in the installation may be stale or incomplete. Reinstall them from the OpenEMR directory using the package manager the release documentation specifies, running as the same user that owns the installation. Keep a copy of the previous dependency state or a backup before reinstalling, so a rollback is possible. The step is done when the install completes without errors and the package files show the new timestamps.

  5. Verify Apache rewrite settings

    Check that the Apache configuration for the OpenEMR site enables the rewrite module and that the directives that route C-CDA requests to the service are present and unchanged from the release defaults. Test the configuration syntax with the Apache configuration check command before reloading, and review any local changes made during hardening, since rules that block direct web access to document directories can also block service paths. The step is done when the configuration test reports no syntax errors and the routing rules match the documented configuration.

  6. Restart the service and check its status

    Restart the C-CDA service and the web server in that order, then confirm the Node.js process is running, listening on port 6661 and logging no startup errors. Read the service logs from the restart window rather than relying on the process status alone. The step is done when the process is up, the port is bound by the expected owner and the logs show a clean start.

  7. Test a C-CDA export end to end

    Generate a C-CDA document for a test patient record in a non-production copy of the data, or a patient record your clinical lead has approved for testing, and review the output document. Check that the document is produced, that it is well formed and that the sections you expect are populated. Record the test patient, the date and the outcome in the change log. The step is done when a test export completes without errors and the output passes your internal review, and any failure is traced back to the step where the fault was found.

Each hand-off in a C-CDA export can fail on the server

The export starts in the clinician's browser, which sends the request to Apache. Apache rewrite rules decide which requests reach the OpenEMR PHP application, so a misrouted path fails before any C-CDA code runs. PHP reads patient data from the OpenEMR database, then calls the local C-CDA service, which runs on Node.js and listens on a local port. The XML document returns through PHP to the browser. When an export fails, check the hand-offs in that order: rewrite rules, Node.js version, port ownership and packages left behind by an upgrade. Everything inside the server boundary is under your control, so these checks run on your own host.

Request path from browser to C-CDA service, with failure points marked.

How the fix differs for bare-metal, Docker and multisite installs

On a traditional server install, OpenEMR, Apache, PHP and the C-CDA service share one host, so the service is started and reached from the same machine that serves the clinical application. Troubleshooting usually means checking the service's runtime on that host, confirming which Node.js binary the service resolves and confirming that no other process holds its port.

  • Where the service runs: As a process on the application host, started by your service manager. Confirm the unit name and startup method in your build.
  • Package reinstall: After an upgrade, the service's dependencies are reinstalled from the OpenEMR source tree on the host, using the commands in the install documentation for your release. Confirm the exact commands for your version.
  • Apache configuration: Rewrite and proxy rules usually sit in the virtual host file or an included file under your distribution's Apache configuration directory. Confirm the file locations on your distribution.
  • Runtime and port checks: Confirm the Node.js version the web server user resolves, which can differ from your interactive shell, and check the port with a local listener query.

After each change, check the service logs and run a test export from the same host, because the web server user's environment is the one the application actually uses.

Security and operational risks while fixing the service

Troubleshooting the C-CDA service usually means opening ports, editing web server rules and handling real patient documents under time pressure. Each of those steps can widen the attack surface of an OpenEMR server that should only serve HTTPS on port 443. The cards below set out the risks to check before and after every fix.

Port exposure beyond the server

Diagnosing a C-CDA generation failure often involves reaching the service directly on its local port, and a firewall rule opened for testing can outlive the session. The service should only listen where OpenEMR can reach it, and external access should stay limited to HTTPS on port 443 as the Securing OpenEMR guidance advises. Before closing a session, check the listening sockets and firewall rules, and confirm that no test rule remains open to other networks.

Securing OpenEMR guide

Setup and admin scripts left behind

Troubleshooting sessions tend to add diagnostic pages, and the setup script is a common leftover. The Securing OpenEMR guide says to remove setup.php and other admin scripts after installation, so any script added or re-enabled during a fix should be deleted once the export works. Compare the web root with the known-good release files after each change to catch anything that was not removed.

Apache rules that weaken HTTPS

Rewrite rules written to route C-CDA requests can accidentally allow plain HTTP or bypass the redirect that forces HTTPS. Confirm that the HTTP virtual host still redirects to HTTPS and that no rule exempts the C-CDA path from the access controls applied to the rest of the site. Test the changed configuration with apachectl configtest and retest from an outside network after every edit.

Direct access to exported documents

Generated C-CDA files contain patient data and can be written to the sites directory while you test. The Securing OpenEMR guidance says to **block direct web access to sites/*/documents**, so a file saved there during debugging must not be reachable by URL. Request a generated file's path from a browser that is not logged in, and confirm the server refuses it.

Securing OpenEMR guide

Test data and debug output

Test exports are often generated from real patient records, and debug logs can capture full document contents or credentials. Use a non-production copy or a synthetic patient for repeated testing, and set a rule for deleting exported files and log extracts once the fix is verified. Ask your team to define who can view these artifacts and where they may be stored.

How to test a C-CDA export before clinicians rely on it

Do not let clinicians rely on a C-CDA export until your team has run a repeatable test against a known test patient and kept a record of the result. Start by choosing one or more synthetic or test patients whose chart contains the sections your clinics actually send (problems, medications, allergies, results, and encounters). Generate the export from the same OpenEMR version, PHP runtime and Node.js setup that production uses, then confirm three things: the document is produced at all, the file is well formed XML, and the content matches what you entered in the chart. Compare the output with the source data field by field, because a document can be well formed and still carry an empty or wrong section.

Repeat the same test after every change that touches the service, including Node.js or PHP updates, reinstalled packages after an upgrade, changes to the Apache rewrite rules, and any change to the port 6661 configuration. Keep a short test log that records the date, the OpenEMR version, the test patient identifier, the commands or screens used, the output file name and checksum, and who reviewed it. The log is what lets you show later which configuration produced a given export and whether a regression appeared after a change.

Conformance to the C-CDA standard is a separate question from whether the export runs. Validate the generated documents with the validation tooling your organization selects, and confirm with your receiving partners which template and validation rules they expect. A testing plan of this kind shows that your own checks were performed and documented. It is not a certification of the export, and DeployOpen does not issue certifications or audit reports. Ask your independent assessor or certification body which evidence they will want to see before you describe the service as validated.

Limits to confirm in your environment

C-CDA generation depends on a stack of details that vary by OpenEMR release, build and support arrangement. The cards below list the limits to verify in your own environment before you change anything, so that a fix does not rest on a version assumption.

Node.js version for your release

The C-CDA service runs on Node.js, and the Node.js version it accepts is tied to the OpenEMR release and packaging you run. Do not assume a version from an older guide or a neighboring install. Check the Node.js requirement stated in the release notes and documentation for your exact OpenEMR version, then compare it with the version installed on the host or container. A mismatch is a common cause of generation failures after an upgrade.

OpenEMR releases

Whether port 6661 is configurable

The C-CDA service listens on a local port, and conflicts with other services on that port are a frequent failure. Before you move the service, confirm in your build whether the port is a configurable setting or is fixed in the code and packaging. If it is fixed, the fix is to free the port rather than change it, and any reverse proxy or firewall rules that point to it must match. Record the result so that the next upgrade does not undo a local change.

Certification status of your version

A change to the C-CDA service can affect how exports are produced, so the certification status of your installed version matters before you patch or reconfigure it. Confirm which OpenEMR version you run, whether that version is covered by the project's certification statements, and what the project's current guidance says about maintaining certification. Ask your compliance lead to record the version and date of any change that touches document generation.

Certification wiki

Vendor support contract scope

OpenEMR is community-supported, and the project lists professional support vendors on its wiki. Confirm in writing whether your contract covers C-CDA generation, Node.js or packaging changes, and fixes to the service after an upgrade. Ask whether the vendor will reproduce the failure on your version, what evidence it needs from you, and whether a fix would be delivered as a patch, a configuration change or a rebuild.

Dependency on your install method

The C-CDA service behaves differently under the Docker image, the Ubuntu installer and a manually built host, so the same symptom can have different causes. Identify how your instance was deployed and which files and packages it uses. Confirm whether a rebuilt image or package reinstall is required after each upgrade, and whether your deployment method supports the Node.js version your release expects.

Your rewrite and proxy settings

Apache rewrite rules and any reverse proxy in front of OpenEMR decide whether export requests reach the service. Confirm which rewrite rules your web server loads, whether they were changed during hardening, and whether the path the C-CDA service expects is still allowed. Changes made to block direct access to document directories or admin scripts can also block legitimate generation requests, so test with the hardening rules in place.

Questions buyers ask about C-CDA troubleshooting

How long does it take to fix a failing C-CDA service in OpenEMR?

The time depends on the cause, and no duration is supplied for this work, so treat any estimate you receive as provisional until someone has reproduced the failure. A Node.js version mismatch or a port conflict is usually quick to confirm once the service logs are read. Problems that involve upgrades, reinstalled packages or web server rewrite rules take longer because each change has to be tested against a real export. Ask the provider to state what they will check first, what evidence will close the ticket, and what happens if the first hypothesis is wrong.

Can our IT team troubleshoot the C-CDA service without outside help?

Often yes, if the team has Linux administration skills, access to the OpenEMR host and someone who can read Apache and Node.js logs. The work follows a clear sequence: confirm the runtime version, check whether port 6661 is in use, reinstall the service packages after an upgrade, review rewrite settings and run a test export. Gaps usually appear in the last step, because a clean service start does not prove that a document is generated and rendered correctly. Teams without a non-production copy of the system, or without anyone who has done an OpenEMR upgrade before, tend to find the work slower.

What does the work need from our team before it starts?

Plan for four inputs. Shell access to the OpenEMR host or container, with the ability to read configuration and service logs, is the first. A test patient with realistic but non-production data lets you confirm an export end to end without exposing live records. A maintenance window matters because restarting services and changing web server settings can interrupt clinicians. Finally, name a person who can approve changes and check the results in the clinical workflow. Ask the provider which of these they need and how they will handle any patient data they see.

What does a fixed-scope C-CDA engagement cover?

A fixed-scope engagement covers a defined set of problems, such as one failing export type on one OpenEMR instance, and it ends with written deliverables. Scope, deliverables and timelines are agreed in writing before work starts, and a quote follows from that written scope. Expect the scope to name the systems involved, the versions in use, the symptoms being addressed, the changes allowed, the tests to be run and the handover notes. Anything outside that list, such as broader interoperability work or upgrades to the whole platform, should be scoped separately.

What drives the cost of a C-CDA fix?

Cost follows the amount of diagnosis and testing, not the number of lines changed. The main drivers are how many systems are involved, whether the fault is reproducible, how many OpenEMR versions and PHP or Node.js combinations must be checked, whether the environment is containerized or hand-built, and how much change control the organization requires. One-time costs are the diagnosis and fix. Recurring costs appear if you want ongoing support, upgrades or retesting after each OpenEMR security release. Ask for the quote to split these items and to state what is excluded.

When should we escalate a C-CDA problem to a partner?

Escalate when the first checks do not isolate the cause within your own change window, when the fault appears after an upgrade and rollback is unclear, or when exports fail intermittently under load. Escalation also makes sense when a clinical or compliance deadline depends on the export, because a partner can bring a tested procedure and written evidence. Before you call, collect the OpenEMR version, PHP version, Node.js version, the Apache rewrite configuration, the relevant logs and the exact failing export. Those details shorten the first conversation considerably.

Does fixing the C-CDA service make our exports compliant?

No. A working service shows that the software produces a document, not that the organization meets its obligations. Certification and HIPAA compliance are assessed by independent auditors and regulators, and DeployOpen does not issue audit reports or certifications. Keep test exports, change records and validation results as evidence, and confirm with your compliance lead which requirements apply to your practice. The OpenEMR compliance pages cover those controls in more detail.

How DeployOpen scopes and supports OpenEMR service fixes

DeployOpen works inside your own infrastructure, and every C-CDA fix starts with a written scope. The scope should name the affected OpenEMR version, the PHP and Node.js runtime on the web tier, the host or container that runs the C-CDA service, the Apache virtual host and rewrite rules involved, and the export test cases that must pass before the fix is accepted. DeployOpen is a Chainscore Labs company and implements, hardens and supports self-hosted open-source platforms in the client's cloud accounts, data centers or air-gapped networks, so the diagnostic commands, configuration changes and logs stay in an environment your team controls. Most engagements are fixed-scope, and the scope, deliverables and timeline are agreed in writing before work begins.

Before you sign off on a scope, ask for the list of changed files, configuration keys and package versions, a rollback procedure for each change, and the test results that show the export path works end to end. Also confirm who is responsible for the staging environment used for retesting and who approves the production change window. A clear written record matters most when a clinic needs to show what changed after an upgrade, because the same questions will come up again during compliance or certification reviews. DeployOpen does not publish a price list. A quote follows from the written scope, so the more precisely the affected components and test cases are defined, the more precisely the quote can reflect the work.

Once the first fix is complete, the work often recurs with each OpenEMR upgrade, a PHP or Node.js change, or a new security release. For that, DeployOpen offers retainers for ongoing support, upgrades and continuous testing. Ask whether a retainer would cover re-running the C-CDA export tests after each OpenEMR release, reinstalling the packages that the service depends on, and reviewing Apache rewrite settings after server changes. Decide early who owns the runbook afterward, since a fix that only one engineer understands becomes a risk the next time the service fails.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.