October DealsAmazon USOctober deal check: compare before you payAmazon 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 NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk11 min

How to Fix SSL Connection Errors on Ubuntu with Apache

A practical, layer-by-layer guide to fixing Apache HTTPS failures on Ubuntu, from refused connections and wrong virtual hosts to certificate-chain and TLS handshake errors.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix an Ubuntu Apache SSL error by identifying the failing layer first: network reachability, Apache’s HTTPS listener, the SSL virtual host, certificate files, the certificate chain, or TLS protocol negotiation. Check each layer in that order, run apache2ctl configtest before every restart, and use OpenSSL with the real hostname so Server Name Indication (SNI) selects the intended virtual host.

The usual repair is to enable mod_ssl, enable the correct SSL site, make sure Apache listens on port 443, point SSLCertificateFile and SSLCertificateKeyFile at matching files, serve the required intermediate certificates, then verify the endpoint with openssl s_client. The commands below apply to Ubuntu’s Apache2 package; paths can differ when you have created a custom layout.

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.

Identify which kind of SSL failure you have

“SSL connection error” describes several different failures. The browser message is useful as a symptom, but the repair depends on where the connection stops.

Symptom Most likely layer First checks
Connection refused No process is accepting the requested address and port, or a firewall is rejecting it DNS result, firewall rules, Apache service state, Listen, and the SSL virtual host’s address/port
Connection timed out Routing, security group, firewall, or an unreachable address Resolve the hostname, test the server’s public address, and inspect host and cloud firewall rules
Immediate protocol error or a page of unreadable characters HTTP and HTTPS are being sent to the wrong listener Use https:// for the TLS port and verify that port 443 is not serving plain HTTP
Certificate name, date, or trust warning Certificate identity or chain Subject Alternative Name (SAN), validity dates, issuer, and intermediate certificates
TLS handshake failure Protocol or cipher negotiation, SNI selection, or a malformed certificate/key setup Test with OpenSSL, specify the hostname with -servername, and inspect Apache’s logs
Apache fails to start after a change Configuration syntax, unreadable key, or an invalid SSL directive sudo apache2ctl configtest, the service journal, and the Apache error log

Do not replace a certificate when the server is not listening, and do not change TLS settings when the request is reaching the wrong port. Keeping the failure layer separate prevents unrelated changes from making diagnosis harder.

#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.

Check DNS, the port, and Apache before changing TLS

Confirm that the hostname reaches the intended server

Resolve the exact hostname users enter, including the www name if it is used. Check both A and AAAA records where applicable. An IPv6 record pointing to a host without a working Apache listener can make some clients fail while IPv4 tests appear healthy.

dig +short example.com A
dig +short example.com AAAA

Compare the returned address with the server you are administering. If a proxy, load balancer, or CDN terminates TLS in front of Apache, test that component separately; the certificate presented to the browser may not be the certificate installed on the origin server.

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.

Verify that Apache is running and listening on 443

sudo systemctl status apache2.service
sudo ss -ltnp | grep ':443'

A running service without a LISTEN socket on the expected address and port still cannot accept HTTPS. Check /etc/apache2/ports.conf and the enabled virtual-host files for a matching Listen 443 and <VirtualHost *:443> (or the specific address you intend to use). Apache’s address and port pairing must align: an SSL virtual host on one address does not answer a connection sent to another address.

Check host and perimeter firewalls

For a server using UFW, inspect its status and allow HTTPS only if your policy requires it:

sudo ufw status verbose
sudo ufw allow 443/tcp

Also inspect cloud security groups, hardware firewalls, and container or load-balancer rules. A timeout commonly indicates that traffic is being dropped before Apache sees it; an Apache log will not contain a request that never reached the process.

Enable Apache’s SSL module and the correct virtual host

Ubuntu’s documented enablement sequence uses mod_ssl and an SSL site configuration. The default HTTPS file is /etc/apache2/sites-available/default-ssl.conf; a production site normally has its own scoped virtual host instead of relying on the default.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Enable the SSL module:
    sudo a2enmod ssl
  2. Enable the default site for a quick wiring test, or enable your site’s SSL file:
    sudo a2ensite default-ssl
    # or, for a custom file:
    sudo a2ensite example-ssl.conf
  3. Check syntax before restarting:
    sudo apache2ctl configtest

    Expect Syntax OK. Fix every reported error before proceeding.

  4. Restart Apache and check its state:
    sudo systemctl restart apache2.service
    sudo systemctl status apache2.service

Ubuntu uses /etc/ssl/certs for public certificates and /etc/ssl/private for private keys by default. A custom path is valid, but the Apache worker must be able to read the key while other users should not have access to it.

Build a correct SSL virtual host

An HTTPS virtual host needs a hostname, a TLS listener, and certificate directives. Adapt the paths and document root to your installation:

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.
<IfModule mod_ssl.c>
    <VirtualHost *:443>
        ServerName example.com
        ServerAlias www.example.com
        DocumentRoot /var/www/example

        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/example-fullchain.crt
        SSLCertificateKeyFile /etc/ssl/private/example.key

        ErrorLog ${APACHE_LOG_DIR}/example-ssl-error.log
        CustomLog ${APACHE_LOG_DIR}/example-ssl-access.log combined

        <Directory /var/www/example>
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
</IfModule>

Use one certificate whose SAN entries cover every hostname served by this virtual host. If several HTTPS sites share an address, each needs the correct ServerName/ServerAlias and certificate. Clients that support SNI send the hostname during the handshake; without a matching virtual host, Apache may return the first enabled certificate, which can look like a certificate failure even though another site’s certificate is valid.

After editing, run sudo apache2ctl configtest. Do not use a successful text editor save as evidence that Apache accepted the configuration.

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

Inspect the certificate, hostname, dates, and key

Read the certificate Apache is configured to use

openssl x509 -in /path/to/server.crt -noout -text

Check the SAN extension, not just the legacy Common Name. The hostname a user enters must appear as an exact DNS name or an appropriate wildcard in SAN. Confirm that the current date falls between Not Before and Not After, and note the issuer. A certificate can be mathematically valid but untrusted if it was self-signed or issued by a CA that the client does not trust.

Make sure the private key belongs to the certificate

For RSA material, compare moduli:

openssl x509 -noout -modulus -in /path/to/server.crt | openssl sha256
openssl rsa  -noout -modulus -in /path/to/server.key | openssl sha256

The hashes must match. For non-RSA keys, compare the public keys instead:

openssl x509 -in /path/to/server.crt -pubkey -noout | openssl pkey -pubin -outform der | openssl sha256
openssl pkey -in /path/to/server.key -pubout | openssl pkey -pubin -outform der | openssl sha256

If the values differ, locate the key that was generated with this certificate or obtain a replacement certificate for the key you intend to keep. Do not edit a key file or paste private-key contents into a ticket or chat.

Check permissions without exposing the key

Apache must read the private key during startup. A permission error can therefore stop the service, but making the key world-readable creates a much larger problem. Keep the file under /etc/ssl/private or another restricted directory, make the owner and group consistent with your distribution’s Apache setup, and grant only the minimum read access required. Verify permissions with:

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.
sudo stat -c '%A %U:%G %n' /etc/ssl/private/example.key

Serve the complete certificate chain

Browsers generally trust a server certificate through one or more intermediate CA certificates. The server must send those intermediates during the handshake. If an intermediate is missing, the leaf certificate may look valid when inspected alone yet fail verification because the client cannot build a path to a trusted root.

Use the certificate file format supplied by your CA. When instructed to use a full-chain file, place the server certificate first followed by each required intermediate, and point SSLCertificateFile at that file. Keep the private key in a separate SSLCertificateKeyFile. Do not send the root CA certificate as a substitute for the intermediate chain.

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

You can test a local chain with:

openssl verify -CAfile ca.crt /path/to/server.crt

For a chain that requires an intermediate supplied separately, provide the appropriate trusted CA file and untrusted intermediate file in your OpenSSL version. The command’s result is meaningful only when the CA file represents the trust store you are trying to validate against.

Test the live handshake with OpenSSL

Use the real public hostname with SNI. Testing only an IP address can select a different virtual host and certificate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
openssl s_client -connect example.com:443 -servername example.com

Read the negotiated protocol, the certificate subject and issuer, the verification result, and the certificate chain printed by the command. A connection that reaches the server but reports verification errors points to trust, hostname, dates, or intermediates; a failure before a certificate is shown points more strongly to the listener or protocol negotiation.

When a client and server disagree about protocol versions, test each supported version explicitly:

openssl s_client -connect example.com:443 -servername example.com -tls1_2
openssl s_client -connect example.com:443 -servername example.com -tls1_3

Availability of TLS 1.3 testing depends on the OpenSSL build. A successful TLS 1.2 test and a failed TLS 1.3 test can identify a version-specific configuration or software compatibility issue; it does not by itself prove that one version should be disabled for every client.

OpenSSL also includes a test server, openssl s_server, which can isolate certificate and protocol behavior away from Apache. Use it only on a controlled test address and never expose a temporary private key or test listener to the public internet.

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

Resolve protocol mismatches and SNI mistakes

Do not send HTTP to the HTTPS port

Apache documents a failure that occurs when an HTTP request is sent to an HTTPS server, or HTTPS is sent to a non-SSL listener. Confirm that redirects and health checks use the correct scheme:

curl -vk https://example.com/

The verbose output shows whether a TCP connection was made and whether a TLS handshake started. A plain HTTP health check pointed at port 443 can generate confusing Apache errors even while browsers work correctly.

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.

Check the virtual host selected by SNI

Always include -servername example.com in OpenSSL tests for named sites. Compare the certificate returned with the certificate configured for that hostname. If the wrong certificate appears, inspect enabled sites and their ordering:

sudo apache2ctl -S

This command lists Apache’s parsed virtual hosts and the address each one claims. Remove stale duplicate definitions, correct the ServerName, and ensure the intended SSL site is enabled.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When local and remote tests disagree

Test the origin locally while preserving the hostname

A test from the server itself can separate Apache from the network perimeter. Connecting to loopback alone is not enough for a name-based site because it may select the default virtual host. Preserve both the destination and SNI name with:

openssl s_client -connect 127.0.0.1:443 -servername example.com
curl --resolve example.com:443:127.0.0.1 -vk https://example.com/

If these local tests fail, concentrate on Apache’s listener, virtual host, certificate, or key. If they succeed while an external test times out or is refused, investigate firewall, routing, NAT, security-group, or proxy rules instead of changing certificate directives.

Account for IPv4 and IPv6 differences

When a hostname has both A and AAAA records, clients may choose either address. Test each address explicitly and confirm that Apache is bound to both where intended. Removing an obsolete AAAA record can restore access, but only after confirming that the address is no longer required by another service. A successful IPv4 handshake does not validate an unreachable IPv6 endpoint.

Distinguish a server problem from a client trust problem

If OpenSSL verifies the chain from a current machine but one browser or device still warns, check that client’s system clock and trust store. Use:

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

An incorrect clock can make a currently valid certificate appear expired or not yet valid. An old operating system may also lack the CA root needed by a modern certificate. Do not weaken Apache’s certificate configuration to accommodate one outdated client without understanding the compatibility requirement.

Inspect the chain actually sent over the network

To see what Apache presents rather than what is stored on disk, request all certificates from the live endpoint:

openssl s_client -connect example.com:443 -servername example.com -showcerts

The first certificate should be the site certificate, followed by the required intermediates. A file containing the correct full chain is not proof that Apache loaded it; the live output is the decisive check. If the output still shows an older certificate, inspect which virtual host is selected and whether a proxy terminates TLS before the request reaches Apache.

Read Apache’s logs when the symptom is unclear

Check the service journal for startup and permission failures:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo journalctl -u apache2 -b --no-pager

Then inspect the main error log and any per-site SSL error log:

sudo tail -n 100 /var/log/apache2/error.log
sudo tail -n 100 /var/log/apache2/example-ssl-error.log

Messages about an unknown directive usually mean a module or configuration file is missing. “Cannot load certificate” and key-reading errors point to paths, permissions, file format, or a certificate/key mismatch. Messages about no shared cipher or protocol version indicate negotiation settings or an old client. Record the exact error before changing a directive; similar browser messages can originate from different Apache failures.

Recover safely when Apache will not restart

  1. Run sudo apache2ctl configtest and correct the first reported error. Later messages can be consequences of that one failure.
  2. If syntax is valid, inspect sudo journalctl -u apache2 -b for a port already in use, an unreadable key, or a failed module load.
  3. Check the certificate and key paths exactly as written, including capitalization and symbolic links.
  4. Temporarily restore the last known-good certificate configuration or disable only the newly changed SSL site with sudo a2dissite example-ssl.conf, then test Apache again. Preserve the faulty files for comparison rather than deleting them.
  5. After the service starts, re-enable the corrected site, run configtest once more, restart, and perform a live OpenSSL test.

Never repeatedly restart a service with an unvalidated configuration. A configuration test is quick and prevents an avoidable outage.

Choose the right certificate for testing or production

Self-signed certificates

A self-signed certificate is useful for controlled testing because it can prove that Apache is listening, the key matches, and TLS encryption is wired correctly. Browsers and operating systems will normally warn because the certificate is not anchored in a trusted public CA. Ubuntu documentation states that self-signed certificates should not be used in most production environments.

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

CA-signed certificates

For a public production hostname, use a certificate issued by a CA trusted by the clients you need to support, with SANs covering the actual hostnames and the complete intermediate chain installed. A CA-signed certificate addresses browser trust, but it does not fix a closed port, a wrong virtual host, an expired certificate, or a mismatched private key.

When comparing a proposed fix, evaluate the failure layer it addresses, whether it is a test or production environment, how SNI affects hostname selection, whether the certificate is self-signed or CA-signed, and how easily you can reverse the change.

Final verification checklist

  • The hostname resolves to the intended server and any IPv6 address is reachable.
  • Firewall and security-group rules permit TCP port 443.
  • apache2.service is active and ss shows a listener on the expected address and port.
  • mod_ssl is enabled and the intended SSL site appears in sudo apache2ctl -S.
  • SSLCertificateFile contains the correct certificate and required intermediates.
  • SSLCertificateKeyFile points to the matching, restricted private key.
  • SAN entries include every hostname users enter, and validity dates are current.
  • sudo apache2ctl configtest returns Syntax OK before restart.
  • openssl s_client -connect host:443 -servername host negotiates TLS and shows the expected certificate.
  • Apache’s journal and error logs are free of unresolved SSL, permission, and listener errors.

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.