# Connection failed: No such file or directory

**URL:** <https://forum.infinityfree.com/t/connection-failed-no-such-file-or-directory/84379>\
**Category:** Hosting Support\
**Created:** [October 14, 2023, 7:04pm UTC](https://forum.infinityfree.com/t/connection-failed-no-such-file-or-directory/84379 "2023-10-14T19:04:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![game\_dev](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/game_dev/32/38343_2.png) [@game\_dev](https://forum.infinityfree.com/u/game_dev)\
**Post date:** [October 14, 2023, 7:04pm UTC](https://forum.infinityfree.com/t/connection-failed-no-such-file-or-directory/84379/1 "2023-10-14T19:04:27Z")

</div>

Greetings, So yesterday my website was doing fine and was working but today  
i go to it and it says:

Connection failed: No such file or directory

[http://dayquiz.free.nf/](http://dayquiz.free.nf/)

the files are there so i don’t get it.

 ![Screenshot_3](https://forum-cdn.infinityfree.net/original/3X/b/6/b6757628d2479b81c40e62ead887f51fa49cb3e8.png)

---

<div class="post-metadata">

**Author:** ![game\_dev](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/game_dev/32/38343_2.png) [@game\_dev](https://forum.infinityfree.com/u/game_dev)\
**Post date:** [October 14, 2023, 7:14pm UTC](https://forum.infinityfree.com/t/connection-failed-no-such-file-or-directory/84379/2 "2023-10-14T19:14:25Z")

</div>

So i went to verify my files and for some reason when uploading the files, the code in it got doubled up and some files got trippled up. its like the upload thought it failed and copied the code 2 times into the file. that is strange.  
has anyone had this issue when you upload that one of your files code gets doubled?

EXAMPLE:

i uploaded a file with

> \<?php session\_start(); session\_destroy(); // Destroy the current session header("Location: ../login.php"); // Redirect to your login page or any other desired page exit(); ?\>

and it came out in the editor as this:

> \<?php session\_start(); session\_destroy(); // Destroy the current session header("Location: ../login.php"); // Redirect to your login page or any other desired page exit(); ?\> \<?php session\_start(); session\_destroy(); // Destroy the current session header("Location: ../login.php"); // Redirect to your login page or any other desired page exit(); ?\> \<?php session\_start(); session\_destroy(); // Destroy the current session header("Location: ../login.php"); // Redirect to your login page or any other desired page exit(); ?\>

---

<div class="post-metadata">

**Author:** ![Greenreader9](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/greenreader9/32/22847_2.png) [@Greenreader9](https://forum.infinityfree.com/u/Greenreader9)\
**Post date:** [October 14, 2023, 7:17pm UTC](https://forum.infinityfree.com/t/connection-failed-no-such-file-or-directory/84379/3 "2023-10-14T19:17:38Z")

</div>

> [@game\_dev](#):
>
> has anyone had this issue when you upload that one of your files code gets doubled?

That can happen when something goes wrong in the FTP transfer process. You can probably blame the one file manager for that one.

Try re-uploading the files via a desktop ftp client like FileZilla

Can you share your database connection code? Be sure to hide your password

---

<div class="post-metadata">

**Author:** ![game\_dev](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/game_dev/32/38343_2.png) [@game\_dev](https://forum.infinityfree.com/u/game_dev)\
**Post date:** [October 14, 2023, 7:18pm UTC](https://forum.infinityfree.com/t/connection-failed-no-such-file-or-directory/84379/4 "2023-10-14T19:18:37Z")

</div>

I corrected the files and still get the error

Connection failed: No such file or directory

i added my database connection info and it was working yesterday but today its not.

hmm.

---

<div class="post-metadata">

**Author:** ![game\_dev](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/game_dev/32/38343_2.png) [@game\_dev](https://forum.infinityfree.com/u/game_dev)\
**Post date:** [October 14, 2023, 7:23pm UTC](https://forum.infinityfree.com/t/connection-failed-no-such-file-or-directory/84379/5 "2023-10-14T19:23:46Z")

</div>

```php

 <?php
 
 //Database connection configuration

$servername = "sql312.infinityfree.com";
 
$username = "if0_HIDDENFORSECURITY";

 $password = "HIDDENFORSECURITY";

$dbname = "HIDDENFORSECURITY_trivia_game";

 // Create a database connection

 $connection = mysqli_connect($servername, $username, $password, $dbname);

 // Check if the connection was successful

if (!$connection) {

die("Connection failed: " . mysqli_connect_error());

 }

 ?>

```

---

<div class="post-metadata">

**Author:** ![game\_dev](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/game_dev/32/38343_2.png) [@game\_dev](https://forum.infinityfree.com/u/game_dev)\
**Post date:** [October 14, 2023, 7:25pm UTC](https://forum.infinityfree.com/t/connection-failed-no-such-file-or-directory/84379/6 "2023-10-14T19:25:19Z")

</div>

ok now all the sudden my site is working again.

maybe a hiccup in the sql server connection?

It is loading now so all is good!

---

<div class="post-metadata">

**Author:** ![Greenreader9](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/greenreader9/32/22847_2.png) [@Greenreader9](https://forum.infinityfree.com/u/Greenreader9)\
**Post date:** [October 14, 2023, 7:26pm UTC](https://forum.infinityfree.com/t/connection-failed-no-such-file-or-directory/84379/7 "2023-10-14T19:26:33Z")

</div>

Glad to hear it!

---

<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:** [October 15, 2023, 2:06pm UTC](https://forum.infinityfree.com/t/connection-failed-no-such-file-or-directory/84379/8 "2023-10-15T14:06:59Z")

</div>

> [@game\_dev](#):
>
> Connection failed: No such file or directory

As you can see in this troubleshooting article, that error means that you are using `localhost` as the database host. But your code seems fine now and so does your website, so all is good now.

> [@Common MySQL Connection Errors](https://forum.infinityfree.com/t/common-mysql-connection-errors/49338):
>
> Many websites use MySQL databases to store information and settings. However, there are some reasons why the connection to the database may fail. This article describes some commonly seen error messages when connecting to a database, as well as some general tips to keep in mind when setting up a database connection. Common Error Messages Using MySQL is great, but the error message returned if there is an issue logging in to your database can be quite confusing. Here are some commonly seen error…

---

<div class="post-metadata">

**Author:** ![system](https://infinityfree-forum-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/0/b024fd3fa88bae093c9576e55c2c94e33f890206.svg) [@system](https://forum.infinityfree.com/u/system)\
**Post date:** [October 22, 2023, 2:07pm UTC](https://forum.infinityfree.com/t/connection-failed-no-such-file-or-directory/84379/9 "2023-10-22T14:07:56Z")

</div>

Closed on October 22, 2023, 2:07pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
