Ask AI
English

Allowed outbound ports on cPanel hosting

cPanel 4 min read

When your website accesses another server, for example by calling a payment provider’s API, connecting to an external database or having a cron job download files, the connection goes out from the hosting server to a specific port. On our cPanel hosting and WordPress hosting servers, the firewall only lets connections out on the ports in the list below; it rejects connections to any other port. This way, a hacked website or a malicious script cannot attack arbitrary services or send data out of the server through a hidden channel. The list is the same for IPv4 and IPv6.

TCP ports

Web services and APIs are almost always reachable on port 443, so most websites need nothing more than that.

Port What is it for?
80, 443 HTTP and HTTPS: websites, APIs, downloads, plugin updates
8080, 8443 Alternative HTTP and HTTPS ports used by some APIs and application servers
465, 587 Sending email through an external SMTP provider, with authentication
110, 995 POP3 and POP3 over SSL
143, 993 IMAP and IMAP over SSL
20, 21 FTP
22 SSH and SFTP
2222, 4231 Alternative SSH and SFTP ports
873 rsync
3306 MySQL and MariaDB
5432 PostgreSQL
1433 Microsoft SQL Server
6379 Redis
27017 MongoDB
2082, 2083 cPanel
2086, 2087 WHM
2079, 2080 cPanel calendars and contacts (CalDAV, CardDAV)
53 DNS
113 Ident
389, 636 LDAP and LDAPS

UDP ports

Over UDP, only name resolution (DNS, 53) and rsync (873) can go out. You cannot reach a UDP-based VPN, a game server or any other UDP service from your hosting account.

Port 25: sending email from your website

Port 25 is the port servers use to pass email to each other. The firewall allows this port only for the server’s own mail server; your website, a PHP script or a cron job cannot connect directly to port 25 of another server. This way, every outgoing email passes through the server’s mail server, the spam filter and the hourly sending limit, and a hacked website cannot send spam by bypassing the mail server.

Your website can still send email, in two ways:

  • Through the hosting account’s own mail server: with PHP’s mail() function, or over SMTP on port 25 of localhost (the firewall does not block this locally). It is more reliable if the website sends with authentication, using an email account created in cPanel; in WordPress plugins (for example WP Mail SMTP), the server name is the mail server of your hosting account and the port is 465 or 587. Creating an email account is described in a separate article.
  • Through an external SMTP provider (Google Workspace, Microsoft 365, email sending services): ports 465 and 587 are open, so you can send with authentication, using the settings your provider gives you.

If a plugin or script tries to connect to port 25 on an external server, the connection is rejected immediately with a “Connection refused” error. In that case, switch it to port 587 (STARTTLS) or 465 (SSL/TLS).

How can you tell that a port is not allowed?

The firewall immediately rejects a connection to a port that is not allowed, instead of leaving it to wait until it times out. The error message is therefore typically:

  • curl and WordPress: cURL error 7: Failed to connect to … port 9000: Connection refused
  • PHP: Connection refused (error code 111)
  • Python: ConnectionRefusedError: [Errno 111] Connection refused

If the connection is not rejected but waits for a long time and then stops with a timeout (cURL error 28: Connection timed out), the cause is usually not our firewall but the remote server or its firewall. How to investigate these errors in WordPress is described step by step in the article on cURL errors 28 and 60.

Testing a connection

In the Terminal interface of the Advanced group in cPanel, or over SSH, you can test the connection from the same environment your website starts it from. Replace the address and the port with your own:

curl -v --max-time 5 telnet://api.szolgaltato.hu:8443 </dev/null
  • If the output shows the line Connected to api.szolgaltato.hu, the port is open and the remote server accepted the connection.
  • Connection refused: if the port is not in the list above, our firewall rejected it; if it is, no service is running on that port on the remote server.
  • Connection timed out: the remote server or its firewall is not responding.

Further tools for network troubleshooting (ping, traceroute, dig) are covered in a separate article.

If you need another port

If a service your website uses needs a port that is not on the list, contact our support team. Tell us the address of the remote server, the port and what it is needed for (for example, “the courier service’s API on port 9443”), and we will check whether it can be allowed. Do not ask for port 25 to send email: ports 587 and 465 are meant for that, and they are open.

A shorter list applies to the web hosting plans (KeyHelp); it is listed in the article on outbound ports on web hosting.

This article is about outbound connections. If the firewall has blocked your own IP address and you cannot reach your website or cPanel because of it, the article on firewall IP blocking will help.

Back: cPanel articles (49)