Home > PHP, Uncategorized > Fix “A connection attempt failed because the connected party did not” PHP error pada yii framework

Fix “A connection attempt failed because the connected party did not” PHP error pada yii framework

Saat saya menggunakan Server2Go untuk menjadikan aplikasi saya menjadi offline CD, saya mendapatkan pesan :

PDO::__construct() [<a href=’pdo.–construct’>pdo.–construct</a>]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306)

padahal, kalau dijalankan di localhost biasa (di PC) tidak terjadi masalah apa-apa. Sempat puyeng juga mencari solusinya. Setelah mencari di om gugel, ternyata masalahnya ada di file main.php yang terletak di htdocs\nama_aplikasi\protected\config\main.php (kebetulan saya menggunakan yii framework).

pada baris ke 67 :

‘connectionString’ => ‘mysql:host=localhost;dbname=nama_database’,

ubah menjadi :

‘connectionString’ => ‘mysql:127.0.0.1=localhost;dbname=nama_database’,

tutup kembali server2Go dengan meng “close” browser nya, lalu dijalankan kembali Server2Go.exe.

Cara ke 2 :

Jika cara pertama tidak berhasil, silahkan pakai cara ke-2, yaitu ubah file hosts yang terletak di C:\Windows\System32\drivers\etc

ubah menjadi komentar baris yang mengandung tulisan  ::1 dengan perintah #

sehingga file hosts menjadi :

# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

127.0.0.1       localhost
#::1             localhost

sumber : google.com; http://blog.blakesimpson.co.uk

Categories: PHP, Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: