Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › CentOS

How to Repair Nginx After a Broken Yum Update on RHEL and CentOS

By Freedom251 Team · · 12 min read

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

If NGINX stopped after a yum or dnf update, do not immediately remove packages or overwrite nginx.conf. First capture the exact error and preserve the configuration, then determine whether the failure is in NGINX itself, an incomplete package transaction, the repository and signing setup, or the RPM database. Each class has a different safe fix.

This runbook applies to RHEL-family systems, including RHEL and compatible CentOS installations. It covers official NGINX packages and RHEL 9 Application Streams, shows how to repair packages without discarding local changes, and ends with service, socket, firewall, and HTTP checks.

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.

Start by freezing evidence

Run the following before changing packages. The output records the operating-system release, the NGINX build options, installed package version, complete package inventory, systemd state, and boot-time journal entries.

cat /etc/os-release
nginx -V 2>&1
rpm -q nginx
rpm -qa | sort > /root/rpm-package-list.txt
systemctl status nginx --no-pager -l
journalctl -u nginx -b --no-pager

Save the command output to your incident record. A package update can change the binary, modules, service unit, or default includes; the original error is often the quickest way to identify which layer failed. Note whether the host is RHEL, CentOS Stream, or another compatible rebuild, and record whether NGINX came from an Application Stream, the official NGINX repository, or an internal mirror. That provenance matters when you later select a reinstall candidate.

Back up configuration and deployment state

Make a copy of the entire NGINX configuration tree before editing anything. Include the files that contain certificates, private keys, enabled virtual hosts, dynamic-module definitions, and deployment-specific systemd overrides. Find certificate and key locations by inspecting the ssl_certificate and ssl_certificate_key directives rather than assuming a standard directory.

sudo cp -a /etc/nginx /root/nginx-backup-$(date +%Y%m%d-%H%M%S)
sudo systemctl cat nginx > /root/nginx-systemd-unit.txt
sudo mkdir -p /root/nginx-systemd-overrides
sudo cp -a /etc/systemd/system/nginx.service.d /root/nginx-systemd-overrides/ 2>/dev/null || true

Keep at least one untouched copy. Do not replace the only known-good configuration with a newly installed sample file. If keys or certificates live outside /etc/nginx, copy those paths separately with permissions intact and restrict access to the backup.

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.

Classify the failure before repairing it

The same “NGINX will not start” symptom can come from four different layers. Use the first matching row below; do not apply RPM-database procedures to a syntax error or delete packages when the repository is the real problem.

Failure class Typical evidence Next action
Configuration or module The service status or journal names a syntax error, missing include, missing shared object, invalid directive, or permission problem. Run nginx -t; fix the first reported file and line, or restore the required module package and path.
Incomplete package transaction yum/dnf reports an interrupted transaction, dependency conflict, unpacking or scriptlet failure, or a package-version mismatch. Keep one repository and module stream, complete or repair the transaction, then reinstall NGINX and any required modules.
Repository or signing Metadata, GPG, unavailable-mirror, or incorrect $releasever/$basearch errors. Correct the repository for the host’s release and architecture, keep GPG checking enabled, and verify the signing key.
RPM database cannot open Packages database, unexpected file type or format, damaged headers, lock exhaustion, or a hanging rpm -qa. Stop repeating NGINX installs. Use the supported Red Hat RPM-database recovery procedure for the host’s major release.

Separate an NGINX error from a package-manager error

Configuration and module failures

If systemctl status nginx or journalctl -u nginx -b points to a directive, include file, permission, or shared-library problem, test the configuration directly:

sudo nginx -t

Fix the first error in the output before addressing later messages; subsequent errors can be consequences of the first missing file or invalid directive. Common post-update causes include a module package no longer being installed, a load_module path that no longer exists, an include file moved to an .rpmnew file, or a directive removed from the selected build. A module compiled for a different NGINX release or CPU architecture can produce an “undefined symbol” or load failure even when the main binary starts, so reinstall modules from the same package family instead of copying libraries by hand.

Incomplete transactions

When the package manager reports a failed transaction, inspect its history and check for unresolved dependencies before changing configuration. On modern RHEL-family systems, examples are:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo dnf history
sudo dnf check
sudo dnf list installed nginx

On systems still using the yum command, use the equivalent history and dependency checks exposed by that release. A transaction that stopped during unpacking or a scriptlet may need the package manager’s transaction-completion or repair operation, followed by a reinstall of the affected package. Select commands based on the exact error and OS release; do not run a destructive erase merely to make the command succeed. Record the transaction ID and failed scriptlet so support personnel can reproduce the event.

Repository and signing failures

Confirm that the enabled repository matches the operating system’s major release and CPU architecture. A repository built for a different release can produce both dependency conflicts and binaries that cannot load on the host. Keep gpgcheck=1; bypassing signature verification hides the trust problem instead of fixing it. Check enabled repository files for stale CentOS paths, incorrect $releasever expansion, or a mirror that no longer publishes the requested architecture. A GPG error is not safely solved by importing an arbitrary key from an unverified website.

Use one coherent package source

Mixing package families is a frequent cause of a broken update. Choose either the RHEL Application Stream appropriate to the host or the official NGINX repository, and keep the selected source consistent for the NGINX package and its modules. Do not install a random RPM downloaded from an unrelated mirror on top of a distribution stream. A reproducible package set should identify the repository URL, enabled stream, package versions, architecture, and signing key.

Official NGINX repository on an RHEL-family host

NGINX’s documented stable repository uses this configuration:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[nginx-stable]
name=nginx stable repo
baseurl=https://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

The stable channel is enabled by default in the documented setup. A mainline channel is optional and should be enabled only deliberately, because changing channels changes the version stream you will receive. Install the repository-management prerequisite first when following those instructions:

sudo yum install yum-utils
sudo yum install nginx

Verify the signing key fingerprint before trusting the repository: 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62. This is a key fingerprint, not a performance measurement. If the key presented by the host does not match, stop and resolve the repository or key-distribution problem. Keep the stable and mainline definitions from being enabled simultaneously unless you have a deliberate pinning and testing policy.

RHEL 9 Application Streams

RHEL 9 provides different NGINX versions through Application Streams. List the streams visible to the host, enable the intended one, and install from that stream:

sudo dnf module list nginx
sudo dnf module enable nginx:stream_version
sudo dnf install nginx

Replace stream_version with the stream shown by dnf module list nginx. The selected stream controls which NGINX version is installed. Do not enable a stream from one source and then force a package from another source to satisfy the transaction. Distribution streams generally favor integration with the RHEL lifecycle, while the official NGINX stable channel follows NGINX’s packaging cadence; compare support coverage, compatibility, signing, and the ability to reproduce the installed set before switching.

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

Repair a failed yum or dnf transaction conservatively

  1. Record the failing transaction. Use dnf history or the release’s equivalent to identify the transaction ID and the package or scriptlet that failed. Preserve the error text.
  2. Correct repository and stream selection. Disable or remove conflicting NGINX repositories, then leave one trusted source enabled. Confirm the host’s release and architecture match the repository path.
  3. Finish the package-manager repair. Use the transaction-completion or dependency-repair command appropriate to the exact error on that OS release. A package manager may need to complete an interrupted transaction before any reinstall can work.
  4. Synchronize and reinstall only after dependencies resolve. On a DNF-based host, a controlled synchronization such as sudo dnf distro-sync nginx can align the package with enabled repositories when the transaction history shows a version mismatch. If the package is present but damaged, use sudo dnf reinstall nginx. On a Yum-based host, use that release’s corresponding reinstall operation.
  5. Reinstall required modules together. If the error names a dynamic module or shared object, identify the package that owns the file and reinstall that package from the same source. Check every load_module path afterward.

Do not use rpm -e --nodeps as a generic repair. Removing dependency checks can leave the service, modules, and other packages in a state that is harder to recover. Likewise, random RPM downloads make the package set difficult to reproduce and can introduce an incompatible ABI. If a transaction cannot resolve after repository cleanup, stop and preserve the diagnostics rather than repeatedly forcing erasures.

Reconcile files changed by the package update

RPM protects local edits by creating comparison files when a package’s configuration changes. Search for both suffixes:

sudo find /etc/nginx -type f ( -name '*.rpmnew' -o -name '*.rpmsave' ) -print
  • .rpmnew: the package supplied a newer file while retaining your existing file. Compare the two and copy only intentional vendor changes into your active configuration.
  • .rpmsave: your previous file was saved while the package installed a replacement. Compare it with the active file before restoring any directives.

Review virtual-host includes, upstream definitions, TLS settings, access-control files, and module declarations. A package update can also change the location or name of a dynamic module. Confirm that each load_module directive points to an installed library for the current architecture; do not copy a module binary from another release. Preserve file ownership, mode, SELinux labels, and private-key permissions when moving a corrected file into place.

Validate before restarting production traffic

Run the syntax test after every configuration or module change:

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

Only continue when it reports a valid configuration. Then restart the service and collect its state:

sudo systemctl restart nginx
sudo systemctl is-enabled nginx
sudo systemctl status nginx --no-pager -l

For a live service, a reload is usually less disruptive than a restart:

sudo systemctl reload nginx

NGINX validates the new configuration during reload. If validation or application fails, the master process rolls back and continues serving with the old configuration; this behavior lets you test a change without replacing a known-good worker set. A restart is still appropriate when the binary or module set changed, but schedule it with awareness of connection impact and confirm the old process has exited cleanly.

Confirm listeners and local HTTP response

sudo ss -ltnp | grep -E ':(80|443)b'
curl -I http://127.0.0.1/

The socket check confirms that the expected process owns ports 80 and 443. The local request verifies that the HTTP stack responds, but it does not prove that every virtual host, TLS certificate, reverse-proxy upstream, or health check works. Test the production hostname with HTTPS separately, including certificate validation, SNI, redirects, and the application endpoint behind each proxy. If the default RHEL configuration is in use, its static content is served on port 80 from /usr/share/nginx/html; a custom deployment may intentionally use different roots and listeners.

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

Check enablement and firewall policy

systemctl is-enabled nginx tells you whether NGINX will start at boot; an active service alone does not guarantee that. On RHEL 9, also perform the documented firewall checks and inspect the active zone, services, and ports:

sudo firewall-cmd --state
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --list-all

Open only the ports required by the deployment. A successful localhost request combined with a blocked external port points to firewall, load-balancer, security-group, or network policy rather than an NGINX package failure. Verify the firewall change in the permanent configuration as well as the runtime state when a reboot must preserve it.

When the RPM database itself is damaged

Stop package changes when RPM cannot read its database, reports damaged headers or lock exhaustion, or hangs during rpm -qa. Repeating yum install nginx cannot repair a database that the package manager cannot open and may create additional locks.

Use Red Hat’s supported RPM-database recovery documentation or subscription support. The recovery method depends on the major release: RHEL 6 through 8 use Berkeley DB for the RPM database, while RHEL 9 and 10 use SQLite. Do not delete database files, run an unverified rebuild sequence, or copy a database from another host without following the procedure for that release.

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

If unrelated packages also fail to query or install, treat the incident as an operating-system package-management outage rather than an NGINX-only problem. Preserve the package list and logs gathered at the start, and escalate before attempting further installs. A Red Hat support subscription is most relevant when the database is corrupt, the host is in production, or the outage exceeds the team’s self-service recovery boundary; verify the applicable program and response terms for your account.

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

Choose the least destructive recovery path

Situation Preferred action Why it is safer
One invalid directive or missing include Fix the named file, run nginx -t, then reload. Leaves the package database and dependency graph untouched.
One NGINX package damaged after a completed transaction Reinstall that package from the same trusted source and reconcile .rpmnew/.rpmsave files. Preserves dependency guarantees and local configuration review.
Interrupted or conflicting transaction Repair or complete the transaction, align the selected repository and stream, then reinstall required packages. Restores a consistent package set instead of masking the conflict.
Repository signature or release mismatch Correct repository metadata, architecture, release variables, and signing-key verification before installing. Prevents incompatible or untrusted packages from entering the host.
RPM database corruption Follow the release-specific Red Hat recovery path or contact support. Database repair requires procedures that vary between Berkeley DB and SQLite releases.

A complete post-repair checklist

  • The original status and journal error are saved.
  • /etc/nginx, TLS material, enabled virtual hosts, modules, and systemd overrides have a separate backup.
  • Exactly one compatible package source and RHEL module stream provide NGINX.
  • Repository signatures are checked and gpgcheck=1 remains enabled.
  • nginx -t succeeds with the intended configuration.
  • The service is enabled as intended and reports active without new journal errors.
  • Ports 80 and 443 are owned by the expected process.
  • A local HTTP request succeeds.
  • External HTTPS, virtual hosts, upstream applications, health checks, and firewall policy are tested for the actual deployment.
  • No RPM-database errors remain; if they do, package installation has stopped and the issue is escalated.

Frequently Asked Questions

How do I repair NGINX after yum broke it without losing nginx.conf?

Copy /etc/nginx, certificates, module files, and systemd overrides before changing packages. Then classify the error, run nginx -t, and reinstall only from the same trusted package source. Review any .rpmnew or .rpmsave files instead of overwriting your active configuration.

Best Value
Sale
UNIX and Linux System Administration Handbook, 4th Edition
  • New
  • Mint Condition
  • Dispatch same day for order received before 12 noon
  • Guaranteed packaging
  • No quibbles returns

Why did NGINX stop starting immediately after a yum update?

The update may have exposed a configuration or module incompatibility, left an interrupted transaction, selected a conflicting repository or stream, or encountered RPM-database damage. The first lines from systemctl status nginx and journalctl -u nginx -b distinguish these cases.

Should I use the RHEL module stream or the official NGINX repository?

Use one coherent source. RHEL 9 Application Streams integrate with the RHEL lifecycle and expose selectable streams; the official NGINX repository provides stable and optional mainline channels. Compare compatibility with the host release, signing-key verification, release cadence, reproducibility, and support coverage before choosing, and do not mix package families blindly.

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

What does the NGINX repository signing-key fingerprint verify?

The documented fingerprint is 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62. It identifies the signing key used for the official RHEL-family repository. Keep gpgcheck=1 enabled and stop if the key presented by the repository does not match.

Is it safe to run rpm -e --nodeps nginx and reinstall?

No. Removing dependency checks can leave NGINX, dynamic modules, and related packages inconsistent. Repair or complete the package transaction, align repositories and streams, and use a controlled reinstall only after dependencies resolve.

How do I know the RPM database, rather than NGINX, is broken?

Errors such as cannot open Packages database, damaged headers, unexpected file type or format, lock exhaustion, or a hanging rpm -qa indicate an RPM-database problem. Stop repeating NGINX installs and follow the Red Hat procedure for the major release: RHEL 6–8 use Berkeley DB, while RHEL 9–10 use SQLite.

What checks prove the repaired service is really available?

Run nginx -t, restart or reload, inspect systemd status, verify enablement, check ports 80 and 443 with ss, and request http://127.0.0.1/. Then test production HTTPS, SNI, certificates, virtual hosts, upstream applications, health checks, and firewall access from an external client.

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.

When should I contact Red Hat support?

Escalate when RPM cannot query or install unrelated packages, the database is corrupt, or a production outage exceeds your team’s recovery boundary. Preserve the package inventory, transaction history, configuration backup, and journal output so the release-specific recovery can be performed safely.

The Bottom Line

Preserve evidence and configuration first. Identify whether the fault is NGINX, the transaction, the repository, or the RPM database; use one compatible signed package source; reconcile RPM configuration files; and validate syntax, service state, sockets, firewall access, and real HTTP traffic before declaring recovery complete.

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.

CentOSDNFLinux TroubleshootingNGINXRHELRPMsystemdYum

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.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

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.