When your website accesses another server, for example by calling a payment provider’s API, connecting to an external database or having a scheduled task download files, the connection goes out from the hosting server to a specific port. On the servers of our web hosting plans (KeyHelp control panel), the firewall only lets connections out on the ports below; it blocks 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.
Allowed ports
| Port | What is it for? |
|---|---|
| 80, 443 (TCP) | HTTP and HTTPS: websites, APIs, downloads, plugin updates |
| 8080, 8443 (TCP) | Alternative HTTP and HTTPS ports used by some APIs and application servers |
| 465, 587 (TCP) | Sending email over SMTP, with authentication |
| 110, 995 (TCP) | POP3 and POP3 over SSL |
| 143, 993 (TCP) | IMAP and IMAP over SSL |
| 22 (TCP) | SSH and SFTP |
| 2222, 4231 (TCP) | Alternative SSH and SFTP ports |
| 3306 (TCP) | MySQL and MariaDB |
| 5432 (TCP) | PostgreSQL |
| 27017 (TCP) | MongoDB |
| 53 (TCP and UDP) | DNS |
Web services and APIs are almost always reachable on port 443, so most websites need nothing more than that. Anything not on the list is closed, for example FTP (21), Redis (6379) and Microsoft SQL Server (1433), as well as everything over UDP except DNS. If your website needs to upload files to another server over FTP, use SFTP (port 22) instead.
Port 25: sending email from your website
Port 25 is the port servers use to pass email to each other. Your website, a PHP script or a scheduled task cannot connect directly to port 25 of another server; outgoing email goes out through the hosting account’s mail server and the spam filter. This way, 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, more reliably, over SMTP with authentication, using an email account created in KeyHelp. In WordPress plugins (for example WP Mail SMTP), the server name is the name of your hosting server and the port is 465 (SSL/TLS) or 587 (STARTTLS). Creating an email account and the connection details are 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 fails. In that case, switch it to port 587 (STARTTLS) or 465 (SSL/TLS).
How can you tell that a port is not allowed?
The connection fails: depending on the program, the error message is Connection refused or Connection timed out; in WordPress, for example, cURL error 7 or cURL error 28. If the port is on the list above and the connection still stops with a timeout, the cause is usually the remote server or its firewall. What the cURL errors mean is explained in the article on cURL errors 28 and 60.
Testing a connection
There is no SSH access on web hosting, so you can use a short PHP file to test whether an address and port can be reached from the server. In the KeyHelp File Manager, create a porteszt.php file in the domain’s folder (/www/ by default) with the following content, replacing the address and the port with your own:
<?php
$host = 'api.szolgaltato.hu';
$port = 443;
$fp = @fsockopen($host, $port, $errno, $errstr, 5);
echo $fp ? "OK: $host:$port" : "$errstr ($errno)";
Then open it in a browser: https://www.pelda.hu/porteszt.php.
OK: api.szolgaltato.hu:443: the port is open and the remote server accepted the connection.Connection refusedorConnection timed out: if the port is not on the list above, our firewall blocked it; if it is, the remote server is not accepting the connection.
Delete the file after the test.
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.
More ports are allowed on our cPanel hosting servers; they are listed in the article on outbound ports on cPanel hosting.