Linux Error: Could not open a connection to host localhost on port 443

In this tutorial we will be examining the port 443 listen and find how to fix it.

Could not open a connection to host localhost on port 443


Test telnet

telnet localhost 443
telnet: connect to address Connection refused


Check if 443 is listening:

netstat -tnl | grep 443


Another command to check if the port is opened

nmap -sS -O localhost | grep -i 443

You would expect something like below output:

443/tcp open https


Ways to fix 443 Errors


Be sure that in ssl.conf the below line is enabled

Listen 443


Be sure that 443 is opened in your firewall whether you are using iptables or any other firewall.


Is openssl installed ?

openssl is the responsible package for SSL, to check if it's installed or not you can run below command:

rpm -qa | grep -i openssl


If you don't have a self-signed certificate, create one

# Generate private key
openssl genrsa -out ca.key 2048

# Generate CSR
openssl req -new -key ca.key -out ca.csr

# Generate Self Signed Key
openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt

# Copy the files to the correct locations
cp ca.crt /etc/pki/tls/certs
cp ca.key /etc/pki/tls/private/ca.key
cp ca.csr /etc/pki/tls/private/ca.csr


Add below line to your SSL conf file in /etc/httpd/conf.d


vi /etc/httpd/conf.d/httpd-ssl.conf

SSLCertificateFile  "/etc/pki/tls/certs/ca.crt"

SSLCertificateKeyFile  "/etc/pki/tls/private/ca.key"


apachectl restart


Add to IPTABLES firewall if needed

iptables -A INPUT -p tcp --dport 443 -j ACCEPT
/sbin/service iptables save
iptables -L -v


Be sure that SSL.conf is loaded

SSL.conf or any other ssl conf files will be inside the conf.d folder, and all the files should be included inside the main httpd.conf like below example:

Include /etc/httpd/conf.d/*.conf

Replace path with the right path of your conf.d folder.

Subscribe to
for video tutorials updates