WinCC 7.4 Server Not Available: Restoring Missing projectname.mdf and projectname.ldf Databases
When a running WinCC V7.4.x project fails to start with a Server not available / Cannot connect to server message immediately after a PC restart, the root cause is almost always the loss of the SQL Server database files (projectname.mdf and projectname.ldf) that back the WinCC project configuration. This article documents the failure mode, isolates the root cause, and provides a verified recovery path for systems where the database files are missing from the project directory.
1. Problem Description and Symptoms
After an uncontrolled shutdown or forced reboot, the WinCC Runtime (or WinCC Explorer) reports the following symptoms when the project is launched:
- Status bar message: Server not available
- Dialog: Cannot connect to server when activating Runtime
- WinCC Explorer may launch, but the project shows a red status icon
- Activating Runtime fails immediately; the project does not start
- An older backup of the same project opened on the same or a different PC reproduces the same error, confirming the fault is in the project files, not the host
- Manual procedures that normally clear transient issues have no effect: deleting
*.dcf/*.dcfiles, removingprojectname.lck, and Save As project all fail - No recent Windows Update has been installed that would explain the regression
When the project folder is inspected, two files are missing that are normally always present:
-
projectname.mdf— primary SQL Server data file -
projectname.ldf— SQL Server transaction log
2. WinCC 7.4 Project Architecture: Where the Database Lives
Every WinCC 7.x project is, from SQL Server's perspective, a pair of attached databases. WinCC uses Microsoft SQL Server (the bundled Express instance, default instance name WINCC) to persist configuration, tag definitions, alarms, and tag logging.
| File | Type | SQL Server Role | Loss Impact |
|---|---|---|---|
projectname.mdf |
Primary data file | Holds the configuration DB (tags, screens refs, users, alarm classes) | Project cannot start; no configuration data exists |
projectname.ldf |
Transaction log | Tracks uncommitted transactions; required to bring the DB consistent | DB cannot be attached; Database is not recoverable state |
projectname.dcf |
WinCC internal | Re-creatable from CS configuration on next open | No data loss |
projectname.dc |
WinCC internal | Re-creatable cache file | No data loss |
projectname.lck |
Lock file | Indicates Runtime is active; safe to delete when closed | No data loss |
When WinCC Runtime starts, the WinCC service attaches the project database to the local SQL Server instance. On a clean exit the database is detached. A power loss, BSOD, or forced kill of sqlservr.exe during a write can leave the database in an attaching or recovery state; a disk fault or accidental deletion can remove the files entirely.
3. Root Cause Analysis
The fundamental reason the standard recovery steps fail is that WinCC's .dcf, .dc, and .lck files are not the source of truth. They are derived and lock artifacts. The source of truth for the WinCC configuration database is the SQL Server .mdf/.ldf pair.
When those files are gone:
- SQL Server has no database to attach for the project.
- WinCC Explorer cannot read the tag list, user list, or picture references.
- Save As Project reads from the same missing DB, so it also fails.
- Reactivating the project produces Server not available because the WinCC server data manager (the SQL-backed internal data manager) has nothing to bind to.
Typical scenarios that produce the loss:
- Disk I/O error or sector reallocation just before shutdown.
- Antivirus or backup software quarantined
.mdf/.ldfon a folder scan during the restart. - Manual or scripted cleanup of the project directory.
- Restore from a corrupted or partial backup that excluded the project root.
- SQL Server service started before the disk on which the project resides was online, attaching to a transient empty path.
4. Pre-Recovery Diagnostics
Before attempting any restore, verify the state of the SQL Server service and the file system.
4.1 Confirm SQL Server Is Running
- Open Task Manager → Details tab.
- Locate
sqlservr.exe. If it is not present, the SQL Server (WINCC) service has not started. - Open services.msc, sort by Name, and verify SQL Server (WINCC) is in state Running and Startup Type Automatic.
- If the service is stopped, start it manually and observe the Windows Event Log (Application channel) for the source
MSSQL$WINCC.
4.2 Verify File System State
- Navigate to the project root, typically
C:\Program Files (x86)\Siemens\Automation\WinCC\WinCCProjects\<projectname>\. - Confirm whether
projectname.mdfandprojectname.ldfexist. Note exact sizes if they are present. - Open the project folder properties → Previous Versions tab. If Shadow Copies is enabled, a recoverable prior version of the files may be available from before the restart.
- Check the Recycle Bin on all drives; accidental deletes land there first.
- If a UPS or storage event occurred, inspect the disk's SMART counters and
eventvwr.mscfordisk/ntfs/volmgrerrors around the failure time.
4.3 Confirm With SQL Server Management Studio
- Launch SQL Server Management Studio (SSMS) and connect to
localhost\WINCCwith Windows Authentication. - Expand Databases. A healthy WinCC project will show a database with the project name (for example,
CC_PCS_07_2018_09_30__11_22_33) in the Online state. - If the project database appears with state Recovery Pending, Suspect, or Restoring, the MDF/LDF are present but inconsistent. If it is missing entirely, the files have been removed.
5. Step-by-Step Recovery Procedure
The recovery strategy depends on whether at least one intact copy of the MDF/LDF pair exists. Walk through the options in order, least destructive first.
5.1 Option A — Restore From Shadow Copy or Recycle Bin
- If Shadow Copies were enabled, right-click the project folder → Restore previous versions → select a snapshot taken before the failure → Restore.
- If the files are in the Recycle Bin, restore them to the project root with their original names.
- Confirm file sizes match an expected MDF (often 5–50 MB for typical projects) plus a smaller LDF.
- Re-attempt WinCC Runtime activation.
5.2 Option B — Reuse Files From the Last Known-Good Backup
This is the practical path when no local copy remains.
- Identify the most recent backup of the project that opened cleanly on a different PC. WinCC Configuration Studio backs up projects as complete folder copies; if the customer's backup script copies only
.mdf/.ldf, ensure it includesGraCS\,Library\, and theprojectname.mdf/projectname.ldffiles. - On a different PC that has a working copy of the same project (or on the same PC under a different Windows user), locate the two files.
- Copy
projectname.mdfandprojectname.ldffrom the working source into the broken project's folder, overwriting any zero-byte stubs. - Start WinCC on the broken PC. The data manager will attach the restored database to the local SQL Server instance.
- Confirm the project activates and the tag list populates.
.pdl files added to GraCS\ after the backup will need to be re-imported because the restored database will not reference them.5.3 Option C — Reuse Files From the Same Project Running on a Different SQL Server
If the project is currently running successfully on PC A but missing the database on PC B, the MDF/LDF from PC A can be detached and copied.
- On PC A, stop WinCC Runtime and close WinCC Explorer so SQL Server detaches the database cleanly.
- Open SSMS on PC A, connect to
localhost\WINCC, right-click the project database → Tasks → Detach. - Copy
projectname.mdfandprojectname.ldffrom PC A's project folder to PC B's project folder. - On PC B, the next WinCC launch will re-attach the database. If SQL Server reports an orphan, attach manually via SSMS: right-click Databases → Attach → Add, point to
projectname.mdf, ensure the LDF path resolves, and confirm.
5.4 Option D — Recreate Project From CS Files When No Database Exists
If no copy of the MDF/LDF exists anywhere, the configuration database is irrecoverable. The project must be rebuilt. Recovery is limited to whatever CS sources are still on disk or in version control:
- WinCC pictures (
GraCS\*.pdl) are stored as independent files and can be retained. - Tag definitions, alarm classes, user administration, time schedules, and the connection to the AS (PLC) live in the SQL DB and are lost.
- Re-create the project in WinCC Configuration Studio, re-import the PDLs, and re-enter the tag database by re-linking to the AS or by importing a previously exported tag list (CSV / TLG).
6. Why the Standard Quick Fixes Do Not Work Here
| Attempted action | Typical purpose | Result in this failure |
|---|---|---|
Delete *.dcf
|
Force regeneration of internal configuration cache | File is regenerated, but the SQL DB it points to is missing |
Delete *.dc
|
Clear stale connection cache | Same as above; cache is rebuilt, still no underlying data |
Delete projectname.lck
|
Clear stale activation lock | Project will appear to be unlocked, but the DB attach still fails |
| Save As project | Re-pack and re-register the project | Reads the missing DB, produces a project that will not start |
| Reinstall / Windows Update | Rule out service or DLL regression | Not applicable; the host stack is intact |
The pattern is consistent: every operation that depends on the SQL database fails in the same way. That is the diagnostic that points to a missing MDF/LDF.
7. Verification Checklist
After the recovery, run this checklist to confirm the project is healthy:
- In SSMS connected to
localhost\WINCC, the project database is in state Online and its Compatibility level matches WinCC V7.4 expectations (SQL 2008 R2 / 2014). - In WinCC Explorer, the project's tag count matches the pre-failure total. Drill into Tag Management → confirm structure, PLC connections, and tag names.
- Activate Runtime. The status bar transitions from yellow (starting) to green (running) within 30–60 seconds, with no Server not available dialog.
- Open a picture from GraCS in Graphics Designer; static and dynamic elements render.
- Force a tag update from a connected AS; the value should appear live in an I/O field.
- Trigger a configured alarm; verify it appears in Alarm Control and is logged to AlarmLogging tables.
- Stop Runtime cleanly. Verify the MDF and LDF remain in the project folder, that the LDF size did not balloon (indicating an un-checkpointed transaction), and that the next cold start is also clean.
8. Preventive Measures
Loss of the project database is the most common cause of unrecoverable WinCC 7.4 downtime. Apply the following controls in the same change window as the recovery:
-
Image-based backups: Use Windows Server Backup or a disk-imaging product that captures the entire
WinCCProjects\<projectname>\directory, including hidden/system files and*.mdf/*.ldf. File-copy backups that filter by extension will silently skip the database. - Enable Shadow Copies on the volume hosting the project, with a minimum of 25% free space allocated to the System Volume Information.
-
Exclusion rules for antivirus: Exclude
*.mdf,*.ldf, and theWinCCProjectstree from real-time scanning. Document the exclusion in the customer's IT change record. - SQL Server service dependency: Ensure the SQL Server (WINCC) service has a dependency on any volume that hosts the project. If the volume mounts late, the service can start in a state where the DB is unavailable.
-
Pre-shutdown grace on UPS: Configure the UPS shutdown sequence to stop the WinCC service (which detaches the DB cleanly) before killing
sqlservr.exe. -
Daily integrity check: Schedule a script that uses
DBCC CHECKDBagainst the project database during a maintenance window. Surface corruption early, before the next restart. - Document the recovery source: Record the location of an offline, known-good MDF/LDF copy (e.g., a hot spare PC, a versioned repository, or a read-only network share) so the recovery procedure does not depend on the customer's word of mouth.
9. Related Error Patterns
| Symptom | Most likely cause | First action |
|---|---|---|
| Server not available after WinCC service restart | SQL Server (WINCC) not started, or project DB not attached | Verify sqlservr.exe in Task Manager; check SSMS for the project DB |
| Cannot connect to server on redundant server pair | Lost connection to the partner server, or partner's SQL instance is down | Check the WinCC Redundancy state in the @RT state tags; ping both nodes; verify SQL on partner |
| Tagging faults in RT but no dialog at startup | DB attached but Tag Management or PLC connection corrupted | Inspect Tag Management → Connection status and the SIMATIC S7 PROTOCOL SUITE diagnostics |
| The database is not recoverable on attach | MDF present but LDF missing or mismatched | Restore both files together; or attach MDF only with REBUILD LOG as a last resort |
| Project starts but Alarm Control empty | AlarmLogging DB attach failed silently | Check SSMS for the CC_Alarms_… DB; review Alarm Logging configuration |
10. Field Notes and Edge Cases
- When copying
.mdf/.ldfbetween PCs, both machines must run the same WinCC major version and compatible SQL Server build. A V7.4 database will not attach cleanly on a V7.3 host. - If the original project path is on
D:\WinCC\…and the recovery PC mounts the project atC:\WinCC\…, the MDF's internal file pointers will still reference the original paths. Update the file paths in SSMS → Database → Files after attach, or re-copy the files to the original path. - Do not start the SQL Server (WINCC) service while a copy of the database is in progress. The attach can race with the file write and produce a torn state.
- If the customer reports the same error on multiple projects on the same PC, the root cause is the SQL Server instance itself, not individual projects. Investigate
ERRORLOGinC:\Program Files (x86)\Siemens\Automation\WinCC\SQL\LOG\first. - Tag logging runtime databases (
CC_TLG_…) and alarm logging runtime databases (CC_ALG_…) are separate from the configuration database. They are typically archived in segments and are more resilient to single-file loss.
Why does WinCC 7.4 show Server not available after a PC restart even when other projects work?
The WinCC configuration for that specific project is stored in projectname.mdf and projectname.ldf on the local SQL Server (WINCC) instance. If those two files are missing from the project folder, the data manager has nothing to attach, and Runtime reports Server not available for that project only. Other projects on the same PC are unaffected because they have their own intact database pair.
Can I just copy projectname.mdf and projectname.ldf from a different project to fix the error?
No. The MDF/LDF pair contains the project-specific tag list, user administration, alarm configuration, and connection definitions. A different project's database will start a project, but it will not be your project. You must copy the files from the same project, ideally from the most recent known-good backup or from a redundant partner running the same project.
What is the role of sqlservr.exe in this error?
sqlservr.exe is the SQL Server (WINCC) Windows service that hosts every WinCC project database. WinCC does not store its configuration in flat files; it stores them in SQL Server databases. If sqlservr.exe is not running, or if the database files it expects cannot be found, WinCC cannot start Runtime and reports Server not available. Always verify the service is up and the MDF/LDF are present before deeper troubleshooting.
Will I lose configuration changes if I restore the database from an old backup?
Yes. Any tag, alarm, user, picture reference, or configuration change made between the backup date and the failure will be lost. New picture files added to GraCS after the backup will not be referenced by the restored database, although the .pdl files themselves remain on disk. Restore both the MDF/LDF and the GraCS folder from the same backup to keep the project internally consistent.
How do I prevent this failure from happening again?
Use image-based or full-folder backups that include .mdf and .ldf files, enable Windows Shadow Copies on the project volume, exclude WinCC project directories from real-time antivirus scanning, ensure the SQL Server (WINCC) service has the correct disk dependencies, and run DBCC CHECKDB against the project database on a maintenance schedule. Document the location of a known-good offline copy of the MDF/LDF pair so recovery does not depend on guesswork.