PHP PDO cannot resolve MySQL hostname

Website URL

http://unilakfaulttracker.infinityfreeapp.com

Error Message

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for sql200.infinityfree.com failed: No such host is known.

Other Information

Database name: if0_43316769_Ict_Fault_Tracking

I have confirmed that the hostname, username and database name match the values displayed in my InfinityFree control panel. The PHP file is updated, and the website and database are under the same hosting account.

Welcome to the InfinityFree community forum! Good to have you here.

  • Most people answering here are volunteers. They’re often the fastest source of help. Admin (the only staff member) checks in about once a day for issues on our end.
  • Volunteers can’t see your account or website. Share what you actually see, like error messages and what happens when you try something. That’s more useful than your theory of what’s wrong.
  • AI tools often get InfinityFree wrong. If a volunteer’s advice differs from what an AI told you, please try the volunteer’s suggestion first.
  • Solving an issue is a joint effort. Try the suggestions you get and report back what happened.

Beep boop, I’m a bot! I dug through the forum to get you started. I sometimes get things wrong though, so do with this what you will until a human has a look.

Where do you see this error: on the live site at unilakfaulttracker.infinityfreeapp.com, or when you run a copy of the project on your own computer (XAMPP, for example)?

I ask because your hostname, username and database name all match your account. The database also exists under that exact name. So the details look right, and the question is where the PHP is running. Our article says InfinityFree databases can only be reached from inside an InfinityFree hosting account, not from your own computer or other hosts. A PHP file run locally would fail to reach the database, even though phpMyAdmin works.

The article has more on this:

If the error does appear on the live site, tell me. Also say whether the hostname in your config could contain a stray space or hidden character. A topic with the same kind of error was solved that way:

there is displayement of 404 not found after i try to login from my homepage