# Can I connect to other servers from my website? (Sockets, cURL and APIs)

**URL:** <https://forum.infinityfree.com/t/can-i-connect-to-other-servers-from-my-website-sockets-curl-and-apis/49348>\
**Category:** Websites and PHP\
**Created:** [March 26, 2020, 11:00pm UTC](https://forum.infinityfree.com/t/can-i-connect-to-other-servers-from-my-website-sockets-curl-and-apis/49348 "2020-03-26T23:00:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Admin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/admin/32/36437_2.png) [@Admin](https://forum.infinityfree.com/u/Admin)\
**Post date:** [March 26, 2020, 11:00pm UTC](https://forum.infinityfree.com/t/can-i-connect-to-other-servers-from-my-website-sockets-curl-and-apis/49348/1 "2020-03-26T23:00:00Z")

</div>

Your website can connect to other servers, for example to call an API, load data from another website or send email through an external SMTP server. This works with functions like cURL, `file_get_contents()` and `fsockopen()`.

However, to prevent abuse, outbound connections are limited to a small set of ports and services.

## Which ports can I use?

| Port | Used for |
| --- | --- |
| 80 | HTTP |
| 443 | HTTPS |
| 587 | SMTP (sending email) |

All other ports are blocked. This means you cannot connect to things like:

- APIs on different ports, like port 8080 or 3000.
- Game servers.
- Remote MySQL or other database servers.
- FTP servers.
- SMTP servers on ports other than 587, like 25 or 465.

Additional ports cannot be opened on request.

> **Sending email with PHPMailer or a similar library?** Make sure you use port 587 with STARTTLS (`tls` encryption). Many examples use port 465, which won’t work.

## Which services are blocked?

Some services are blocked entirely because of abuse, even on the allowed ports:

- Discord (including webhooks and bots)
- Telegram (including bots)
- Cloudflare Workers
- Google Apps Script

Connections to these services will fail. Consider upgrading to [premium hosting](https://www.infinityfree.com/premium/) if you need to access these services, or use an alternative service to the ones listed above.

## What errors will I see?

### Blocked ports

Connections to blocked ports are not refused, they time out. Your page may load for a long time before you see an error like one of these:

- `cURL error 28: Connection timed out after 10001 milliseconds`
- `cURL error 7: Failed to connect to example.com port 3306 after 130000 ms: Connection timed out`
- `fsockopen(): Unable to connect to example.com:21 (Connection timed out)`
- `file_get_contents(https://example.com:8080/): Failed to open stream: Connection timed out`
- `SMTP ERROR: Failed to connect to server: Connection timed out (110)` (PHPMailer)

If you see a timeout, check which port your code connects to. If it’s not 80, 443 or 587, the connection is blocked.

### Blocked services

Blocked services may not resolve at all, so you’ll see an error about the host name instead:

- `cURL error 6: Could not resolve host: discord.com`
- `php_network_getaddresses: getaddrinfo for discord.com failed: Name or service not known`

These errors can also be caused by a typo in the host name, so double check the address first. If the address is correct and the service is on the list above, it’s blocked.

> **Using a library like Guzzle or Laravel’s HTTP client?** These wrap cURL, so the error message usually contains one of the cURL errors above.

## Can I get a fixed IP address for outbound connections?

No. Outbound connections from your website don’t come from a fixed IP address, and IP allowlisting for outbound connections is not supported.

You can check which IP address your website currently uses with a PHP file containing:

```php
<?php echo file_get_contents('https://ifconfig.me');

```

However, this IP address is shared with many other websites and can change at any time. So you cannot use it to allowlist your website with an API, payment provider, database server or other service that requires a fixed IP address.

---

<div class="post-metadata">

**Author:** ![Topher7lol](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/topher7lol/32/59404_2.png) [@Topher7lol](https://forum.infinityfree.com/u/Topher7lol)\
**Post date:** [May 19, 2025, 12:18am UTC](https://forum.infinityfree.com/t/can-i-connect-to-other-servers-from-my-website-sockets-curl-and-apis/49348/2 "2025-05-19T00:18:12Z")

</div>

are there external/other ways to get game server ports, say prodigy style, just like 3 different servers you could use?

---

<div class="post-metadata">

**Author:** ![twineee.rf.gd](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/twineee.rf.gd/32/61483_2.png) [@twineee.rf.gd](https://forum.infinityfree.com/u/twineee.rf.gd)\
**Post date:** [May 19, 2025, 3:09am UTC](https://forum.infinityfree.com/t/can-i-connect-to-other-servers-from-my-website-sockets-curl-and-apis/49348/3 "2025-05-19T03:09:29Z")

</div>

So does this mean that we are technically allowed to make (not necessarily host) chat scripts on here?

---

<div class="post-metadata">

**Author:** ![Admin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/admin/32/36437_2.png) [@Admin](https://forum.infinityfree.com/u/Admin)\
**Post date:** [May 19, 2025, 6:45am UTC](https://forum.infinityfree.com/t/can-i-connect-to-other-servers-from-my-website-sockets-curl-and-apis/49348/4 "2025-05-19T06:45:33Z")

</div>

@Topher7lol I’m not sure what you mean by that.

@twineee.rf.gd No, chat scripts are still not allowed. I’m also not quite sure how you came to that conclusion. Note that this articles is just about socket functions, not Websockets, which is a very different technology.

---

<div class="post-metadata">

**Author:** ![twineee.rf.gd](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/twineee.rf.gd/32/61483_2.png) [@twineee.rf.gd](https://forum.infinityfree.com/u/twineee.rf.gd)\
**Post date:** [May 19, 2025, 12:24pm UTC](https://forum.infinityfree.com/t/can-i-connect-to-other-servers-from-my-website-sockets-curl-and-apis/49348/5 "2025-05-19T12:24:21Z")

</div>

I’m not a socket person, so I don’t really know what I’m talking about.

---

<div class="post-metadata">

**Author:** ![Topher7lol](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/topher7lol/32/59404_2.png) [@Topher7lol](https://forum.infinityfree.com/u/Topher7lol)\
**Post date:** [May 20, 2025, 12:04am UTC](https://forum.infinityfree.com/t/can-i-connect-to-other-servers-from-my-website-sockets-curl-and-apis/49348/6 "2025-05-20T00:04:10Z")

</div>

I mean like, when you play a game, it connects to a server so you can play with other people like multiplayer.

---

<div class="post-metadata">

**Author:** ![mizuena](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/mizuena/32/55901_2.png) [@mizuena](https://forum.infinityfree.com/u/mizuena)\
**Post date:** [May 20, 2025, 4:53am UTC](https://forum.infinityfree.com/t/can-i-connect-to-other-servers-from-my-website-sockets-curl-and-apis/49348/7 "2025-05-20T04:53:08Z")

</div>

you could probably make a live chat without sockets  
just add a send message box input where the user sends a message and a box were the messages show up and the message gets sent into a MySQL database and then you can use php echo to fetch those messages from the MySQL database

---

<div class="post-metadata">

**Author:** ![Admin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/admin/32/36437_2.png) [@Admin](https://forum.infinityfree.com/u/Admin)\
**Post date:** [May 20, 2025, 7:42am UTC](https://forum.infinityfree.com/t/can-i-connect-to-other-servers-from-my-website-sockets-curl-and-apis/49348/8 "2025-05-20T07:42:16Z")

</div>

That clarifies it a bit, but I still don’t see how it relates to website hosting.

If I were to make a game with PHP, I would just use HTTP calls to send data to other servers. And if it were to run in a browser, I think I’d use WebRTC to setup live peer-to-peer data connections directly between people, which I don’t think needs anything on the hosting side to work.

And if you’re talking about having a desktop or mobile game connect to your website for some features (highscores, social functions, etc.), then you won’t be able to do that anyway. Non-browser access is blocked on our hosting. And to be clear: **this article only relates to OUTBOUND sockets**. You cannot setup your own server that listens for connections on a custom port. That’s just not possible with web hosting.
