Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3283510
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:03:00+00:00 2026-05-17T20:03:00+00:00

This does not work with my PHP 5.3.3 installation on WAMP / Windows 7:

  • 0

This does not work with my PHP 5.3.3 installation on WAMP / Windows 7:

mysql_connect('localhost', 'root', '');

After Maximum execution time, this error is presented:

Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306)

Warning: mysql_connect() [function.mysql-connect]: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

This works:

mysql_connect('127.0.0.1', 'root', '');

I’m wondering if it has something to do with this, from the PHP docs:

Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket (named pipe on Windows). If you want to use TCP/IP, use "127.0.0.1" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as in your PHP configuration and leave the server field blank.

This is from my php.ini:

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
; http://php.net/mysql.default-socket
mysql.default_socket =

Is this a bug, or what is going on?


Update: I’m using MySQL 5.1.36 something, and I can connect to it otherwise. Forgot to mention, but this works with PHP 5.3.0 and 5.2.11. Ofcourse I can just change localhost to 127.0.0.1, but I want to know why I can’t use localhost.


Update 2: Adding (uncommenting) 127.0.0.1 localhost to the hosts file made it work. But why is this necessary?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:03:01+00:00Added an answer on May 17, 2026 at 8:03 pm

    Filed a bug with PHP. The problem is with MySQL, and has to do with it not correctly connecting to all possible IP addresses for a domain.

    Solution? Don’t use host names to connect to databases, if it isn’t absolutely necessary. This might also have a positive impact on performance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

// why does this not work PHP in XAMMP stack // error: strtotime is
I'm trying to understand why this does not work. (Basic example with no validation
My Java application is saving stuff in 'user.home' but on windows this does not
This code does not seem to compile, I just need to write something to
I hope this question does not come off as broad as it may seem
Note that this function does not have a { and } body. Just a
I am completely stumped as to why this code does not get any SDL
I tried this but it does not seem to be valid syntax. <xsl:element name=$myElementName></xsl:element>
YUI Compressor does not accept wildcard parameters, so I cannot run it like this:
I get this error: System.Reflection.TargetException: Object does not match target type. when trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.