PHP web sockets - can't bind to host - php

I'm trying to follow this tutorial:
http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/
But, for love nor money, I couldn't get a response out of the console.
I loaded up the startDeamon manually and found it was failing to bind to my (local) host.
Warning: socket_bind() [function.socket-bind]: Host lookup failed [-10001]: Unknown host
My local server is running on http://localhost:33. I have specifying my host as both localhost and 127.0.0.1, with and without http, and with and without specifying the port, but no joy.
Can anyone help me out?
Thanks in advance

Try using port 12345 instead of 33.

remove the http:// part and just try access it as localhost

you cannot use localhost, or 127.0.0.1 when dealing with sockets, but need to use the domain/host name or host IP address instead. It is explained as a user experience in the PHP5 manual section

Related

Cannot connect to mysqli. Error no 2005 [duplicate]

I was using mysql 5.6.11,it usually turned down and show me this:
2005 - Unknown MySQL server host 'localhost'(11001).
Currently my resolution is to turn off the network,than it return to normal.I had searched a lot,but no answer is revalent to it.So,does anyone knows the reason?
ERROR 2005 (HY000): Unknown MySQL server host 'localhost' (0)
modify list of host names for your system:
C:\Windows\System32\drivers\etc\hosts
Make sure that you have the following entry:
127.0.0.1 localhost
In my case that entry was 0.0.0.0 localhost which caussed all problem
(you may need to change modify permission to modify this file)
This performs DNS resolution of host “localhost” to the IP address 127.0.0.1.
I have passed through that error today and did everything described above but didn't work for me. So I decided to view the core problem and logged onto the MySQL root folder in Windows 7 and did this solution:
Go to folder:
C:\AppServ\MySQL
Right click and Run as Administrator these files:
mysql_servicefix.bat
mysql_serviceinstall.bat
mysql_servicestart.bat
Then close the entire explorer window and reopen it or clear cache then login to phpMyAdmin again.
The case is like :
mysql connects will localhost when network is not up.
mysql cannot connect when network is up.
You can try the following steps to diagnose and resolve the issue (my guess is that some other service is blocking port on which mysql is hosted):
Disconnect the network.
Stop mysql service (if windows, try from services.msc window)
Connect to network.
Try to start the mysql and see if it starts correctly.
Check for system logs anyways to be sure that there is no error in starting mysql service.
If all goes well try connecting.
If fails, try to do a telnet localhost 3306 and see what output it shows.
Try changing the port on which mysql is hosted, default 3306, you can change to some other port which is ununsed.
This should ideally resolve the issue you are facing.
Follow these steps to fix this error
Use \connect root#127.0.0.1 instead of \connect root#localhost
if it doesn't work then go to C:\Windows\System32\drivers\etc\hosts and check the IP address attached to host name.
use that IP, so it will be.
\connect root#the_ip_address_you_found

Can't connect to remote firebird server using ibase_connect() [duplicate]

I'm trying to connect to a remote Firebird database "test" (alias already added). It is not an embedded server, and is installed on VM with IP 192.168.1.147.
Here is my connection string:
User=sysdba;Password=masterkey;Database=test;DataSource=192.168.1.147
However I got an error:
FirebirdSql.Data.FirebirdClient.FbException (0x80004005): Unable to complete network request to host "192.168.1.147". ---> Unable to complete network request to host "192.168.1.147".
I've done some research on that but haven't got a clue yet. Some help needed. Thanks
My IP address is 192.168.2.108, and I can ping that server IP successfully
Make sure that
Firebird is running
Firebird is listening on port 3050 on the specified IP (or on 0.0.0.0)
Your firewall allows access to port 3050
You're using the correct host name
For Linux, the Firebird port is closed by default. You need to modify RemoteBindAddress in /etc/firebird/2.5/firebird.conf from
RemoteBindAddress = localhost
to
RemoteBindAddress =
and restart service.
Make sure you have excluded tcp port 3050 in VMs' firewall.
Ok. I think your connection to firebird is faililing because the firebird client looks up the network service file by name and does not find gds_db in the services file.
If your connection string refers to the host by using IP, the Client might fail to identify it because it gethostbyname() and not by IP
Manually include this in the file and you should be fine.
C:\windows\system32\drivers\etc\services

php postgreSQL error

I am getting the error
Warning: pg_connect() [function.pg-connect]: Unable to connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host "::1", user "user_bch", database "test_bchOrder", SSL off in /home/www2.mysite/connect.php on line 8
on a postgreSQL php connection page. I wonder if it is because the domain is www2 so that my host is not 'localhost'. Perhaps it is something else. This is the server. Grateful for any help!
Thanks
My comment as an answer:
Are you using IPV6 on your server? If you dont use it, edit your /etc/hosts and remove ::1 from your list. Or else, make sure you configure pg_hba.conf correctly to use IPv6

Apache / PHP Unable to communicate with Tomcat JavaBridge

My project uses PHP JavaBridge, I have installed WAMP, JRE 6.0, and Tomcat 6.0.32
I can now access http://localhost:8080/ successfully but when I run my PHP site it gives me the following error
warning: fsockopen() [function.fsockopen]: unable to connect to localhost:8080 (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. )
Can anyone please help me with this issue?
EDIT
Forgot to mention that I am using Windows 7
My comment above worked as a solution and hence this answer, so that in future others get it.
Can you 127.0.0.1:8080 instead of localhost:8080? See what do you get?
fsocketopen takes the hostname and it should be a valid domain, in your case, (in general) it could be a valid domain as long as you have an entry for localhost in your hosts file (C:\Windows\System 32\drivers\etc\hosts). See if you have something similar to that.

file_get_contents(): No such host is known error

I am using the file_get_contents function to get the URL into a string:
$contents = file_get_contents("http://google.com");
But, I am getting the following error:
file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: No such host is known.
How can I solve this in my localhost?
Your "localhost" cannot resolve the name google.com to an ip address, which means your machine doesn't/can't reach a valid dns server.
This probably doesn't only affect php. Try ping google.com on the console of that machine. Does this complain about the unknown host, too?
The steps necessary to solve the problem depend on what your "localhost" is (operating system, flavour/distribution, ...) and how it is connected to the internet.
It is because you need to turn on allow_url_fopen in php.ini
Check your localhost and username.
Like if you are using Xampp, in the host column type Localhost
and the database name
and last but not least the username with root, and then install.
It's quite easy but if you missing it, it's gone be very upsetting.

Categories