Localhost refused to connect Xampp issue - php

i am trying to connect my site from others computers on local network. I can access the site from my system IP address but issue is this when i entered the username and password it will redirect the page from 192.168.0.2/ppp/login to localhost/ppp/auth/login and shows thee error localhost refused to connect.

localhost usually points to 127.0.0.1 . So, if you are getting redirected to localhost/login/ppp then the issue with your site's code. Don't redirect to http://localhost/login/ppp. Just do a redirect to /login/ppp instead.
The reason connection is refused is because the other PC doesn't have XAMPP (or any other web server) running on it.

your only need to change the config.php file in controllers. write your IP instead of localhost. Your code will run properly on network.

Related

Connect remotely to cpanel Database with php

I am trying to access to the database of my live website from localhost. My website is working on cpanel hosting.
I created database and added user to that database but can not connect to this database from my localhost .
this is the code of database information
<?php
$conf['dbuser']='admin_root';
$conf['dbpass']='rootroot!##$';
$conf['dbname']='bsaiiian_os';
$conf['dbhost']='example.com';
$conf["title"]='DEMO';
?>
I think the problem is from $conf['dbhost'] variable where I'm putting the url of my site and not sure if that is right.
When I'm uploading my script to the hosting and put
$conf['dbhost']='localhost';
the connection is established .
this is error message:
Connection failed: No connection could be made because the target machine actively refused it.
Due to security reasons cPanel's MySQL requires that you allow your IP in order to have access.
This is done through:
cPanel -> Remote MySQL Connection
You need to navigate there and allow your local computer's IP in order to make the connection.
Side Note: This stands true for all IPs, even the server's one that your account is hosted on. You will see your cPanel account's IP already present in there - this is to allow access to MySQL for any files from your cPanel account

Not able connect mobile to WAMP

I am using WAMP(version 2.4.9) to host a local server on my pc. My pc is connected to wifi and the ip address is 10.192.48.252 . The port is 420. When I type http://10.192.31.222:420/ in the browser of pc, I get the wampserver homepage as it should be but when I type in the same address in my mobile browser, I get the following error
Forbidden
You don't have permission to access / on this server
I have connected both my pc and mobile over same wifi network. I have set "Require all granted" in httpd.conf file and made 420 accessible through firewall. Please help.
I was also having the same issue as yours. Try XAMPP. Its working fine for me. It has no port issue.

Remote MySQL database connection using php

I'm trying to connect to a remote database on a server which is accessed through cPanel.
I created a user name and associated it with a database. I'm using:
I'm confused on the host name to use. I tried using the Main Domain name in the left menu panel in cPanel with the port number 3306 but it wouldn't work. I used the shared IP as well with the port number that that wouldn't work as well. I have added my local machine IP to the remote databases page in the cPanel as was told in a post but finally I'm not able to connect to the database.
On echoing the mysql_error(), I get:
Can't connect to MySQL server on 'host_name' (4)
Any help would be great!
your hosting site will specify which name should be used for the host
in hostinghood.com they says that to use localhost itself as host name
so check what your hosting site says about it

mysql_connect not working in a server over a VPN

My "mysql_pconnect() / connect()"` function doesn't work on a server over a VPN.
I used the VPN to access the server where in there I created a PHP website. When I run my website it's a blank page. I was wondering why it is a blank page, so I find the error, now the error is the database connection. but it's just the same with my localhost, and the website on my localhost is working. but when I transfer my website to the server it's not working. is there something to do with the VPN? My user and pass to connect to the mysql is correct.
main.php
error_reporting(E_ALL);
$settings_dir = "./settings";
require_once("$settings_dir/database2.php");
//etc etc codes..
database2.php
$conn=mysql_connect("localhost","root","passw0rd");
thats because you cant give the same arguments to mysql_pconnect() which you gave in case of your localhost.because where you hosted your website,there u will have diffrent server name ,DBname and DB password.
mysqli_connect(server,user,pwd,newlink,clientflag)
here the first argument is server which is the hostname,in case of local server its localhost but when you are using any remote server than u need to specify that server name.similarly username and password will be different for that server.
read here
http://www.w3schools.com/php/func_mysql_connect.asp

canot establish connection to localhost through facebook application

i have created a new Facebook application and i used the following url as canvas url http://localhost/my_app/
my code works perfectly on localhost, but when i try to cal my application using the following url : apps.facebook.com/leenaaps its displays the following error:
Unable to connect
Firefox can't establish a connection to the server at localhost
what could be the problem exactly?
You most likely do not have a local webserver running. If you do, it might be possible that Facebook uses https:// but you did not configure/enable SSL.
localhost is resolved to ip 127.0.0.1 and this is the local loopback address whcih means it is not routable and cannot be accessed from the internet, So you cannot use it in your canvas url.
You have to use a valid and active domain name like domain.com. If you don't have a public web server you may use some DDNS service, google it some are free

Categories