Can't connect to localhost - Connect Error (2002)
Posted by: erikdal (---.customers.ownit.se)
Date: August 25, 2021 11:37PM

Hi

After working fine during years, suddenly I can't connect to local host.
MySQL is up and running but when I launch my application and try to connect to the database I get a Connect Error (2002).

The PHP error log shows a fatal error:
[25-Aug-2021 22:59:44 Europe/Stockholm] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 159591562 bytes) in D:\wamp64\scripts\refresh.php on line 2350
[25-Aug-2021 23:00:23 Europe/Stockholm] PHP Warning: mysqli::__construct(): (HY000/2002): Det gick inte att g�ra en anslutning eftersom m�ldatorn aktivt nekade det.
in D:\wamp64\www\BBK\ext\incl\connection.php on line 34

I am running WampServer Version 3.1.9 - 64bit
Apache/2.4.35 (Win64) PHP/7.2.10 - Port defined for Apache: 80

How to fix this annoying problem?
/Erik

Options: ReplyQuote
Re: Can't connect to localhost - Connect Error (2002)
Posted by: Otomatic (Moderator)
Date: August 26, 2021 09:13AM

Hi,

> Allowed memory size of 134217728 bytes exhausted (tried to allocate 159591562 bytes

Right-Click -> Tools -> Empty logs -> Empty all logs files -> Y

> WampServer Version 3.1.9

- Verify that all VC ++ packages are installed and with the latest versions.
To do this, use the tool:
Checks VC++ packages installed
Do not use a previously loaded tool. Make a new download to make sure you are using the correct version.[/u)
To download missing packages, do not rely on Microsoft links, they are not reliable, download packages on http://wampserver.aviatechno.net in section Visual C++ Redistribuable Packages
Do not forget that if you have a 64 bit Windows, you must install both 32 and 64 bit versions of each package.
You must install each package "as an administrator", so right-click the exe file and then run as Administrator.

- Apply Update 3.2.5 to your version of Wampserver
Wampserver update 3.2.5

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Can't connect to localhost - Connect Error (2002)
Posted by: erikdal (---.customers.ownit.se)
Date: September 01, 2021 10:02PM

Hi again

Now I have removed the old version of Wampserver and reinstalled the latest version 3.2.3 and upgraded it to 3.2.5. It works OK.

Now to the next issue.
For special reasons I need to run MySQL using a different port than the default 3306.
I found the function to change MySQL port to 3308, tried it and MySQL is running OK.

However, my web projects failed to connect to the data bases - Connect Error (2002).
After some investigation I found the the function to change MySQL port number does not change the port number in the php.ini file in the directory D:\wamp64\bin\php\php7.3.21\phpForApache.ini.

After changing the mysqli.default_port in this file are my web project running OK.

To me this seems to be a BUG that needs to be fixed.

Regards
Erik

Options: ReplyQuote
Re: Can't connect to localhost - Connect Error (2002)
Posted by: RiggsFolly (Moderator)
Date: September 01, 2021 11:56PM

Well as there is only one port that can be set in the PHP.INI and we provide MYSQL and mariaDB both of which has to use a port and of course a different port, then which one should we auto change and which one should be ignore.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Can't connect to localhost - Connect Error (2002)
Posted by: Otomatic (Moderator)
Date: September 02, 2021 08:44AM

Hi,

> To me this seems to be a BUG that needs to be fixed.

Since the dawn of time, the default port for MySQL is and has always been 3306.
It is well specified in the MySQL documentation that if the port used is not the default port, it must be specified in the connection procedures.
This is well reminded in :
Left-Click -> Help MariaDB - MySQL
or
Right-Click -> Help -> MariaDB - MySQL

This is also reminded during the installation of Wampserver :
For the use of MariaDB and MySQL
⦁ See the file : wamp(64)\mariadb_mysql.txt

It is also reminded at the end of the 3.2.5 update, in the changelog displayed
To use or inactive MariaDB or MySQL, read the file mariadb_mysql.txt

All you had to do was read

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote


Sorry, only registered users may post in this forum.