Drupal error when accessing sites: Can't get hostname for your address - drupal

I'm getting the following error when trying to access sites on my server through the browser. I can ssh to the server and I tried running a flush hosts command but that didn't do anything. The host in question is in the mysql user table and has a username/password and all relevant privs. This issue appeared since an office move and the server was switched back on. I can only think it of being a network issue of some sort.
PDOException: SQLSTATE[HY000] [1042] Can't get hostname for your address in db_table_exists()
How do I resolve this?

I think you need to check if the mysql hostname defined in $databases['default']['default']['host'] of the Drupal sites/default/settings.php file is reached by the machine where drupal is running.
Try to connect to ssh and do a ping or a telnet with the hostname.
Instead of the hostname try using the ip address. Otherwise, if the hostname is not resolved, try adding it to /etc/hosts if you're on linux.

Related

Symfony 4 swiftmailer configuration issues

I have tried setting up SMTP in the dotenv file:
MAILER_URL=smtp://mydomain.nl:25?encryption=tls&username=noreply%mydomain.nl&password=***`
And I've sent an email using php bin/console swiftmailer:email:send. This gave me an error:
[app] Exception occurred while flushing email queue: Connection could not be established with host webmail.mydomain.nl [Connection timed out #110]`
So I assumed this is caused by the firewall. So then I tried to send an email via an online SMTP tester and the email got sent and all worked as expected.
However, this still does not work on my server. Even after turning off the firewall on my (Windows) VPS, the same error persists.
My setup is as follows:
I have a VPS (WINDOWS) with plesk where I host my domain and the mail server.
I also have a home server (CENTOS) where I host my subdomain with plesk.
What am I overlooking? What could be the cause of this issue?
Some host providers block 465 and 25 port. So only 587 is left to use. First, contact your host provider and ask if they are blocking SMTP ports. And if not please come back with more information and server config.
So apparently, please correct me if im wrong. This is what I think I did wrong:
I have a subdomain from my main plesk which I host on my home server. The project i'm working on is running from there.
The main domain with that plesk account is running on a VPS with the mailserver.
As it turns out (I think) my ISP from my home internet has restricted access to port 25. And thats why my home server cant access the mail server.
I tried to disable firewalls everywhere, even routed the ports in my router to my home server, nil fix. (please note that i tried to telnet to several SMTP servers not just my own) with all access rejected.
I tried it with another port (465) from my home server and it works now.
At the end using another port did the trick. I am however not sure that this is the issue. But this is just my guess.

Creation of AMI from operating wordpress site yield "connection refused" with elastic ip

I created an AWS server and installed wordpress with an elastic ip address and verified that the default website was up and running.
I wanted to make a backup image at that point so that I could use it as a beginning point for other websites. However, after getting the AMI running and attaching the elastic ip address to it, I got an "connection refused" error. I can both SSH and FTP into the server, but the wordpress site is offline. I then switched the elastic ip back to the original server and got the exact same issue.
I'm guessing that this is a "change of ip" type error(?) (although, when I've seen that before, the connection has never been outright refused... it usually allows at least access to the admin area of the website) but I thought by using an elastic ip address that I would avoid that. I'm also confused by the error in the first server, since the database still has that address.
Any ideas about how to troubleshoot something like that? Is there anything else that it could be?
Well.... I missed something vital.
Using an AMI works just fine with an elastic ip address. I had forgotten to make sure the webserver (httpd) and mysqld were running with :
service httpd restart
and
service mysqld restart
What made it click was reading that the main reason for this error is that there is listener to the incoming data.
Duh.

Google analytics code fires twice on transaction page of my website. [duplicate]

I am getting error:
"Lost connection to MySQL server at 'reading initial communication packet, system error: 0"
while I am going to connect my db.
If I am using localhost everything is working fine.
But when I am using my live IP address like below, it's getting error:
mysql_connect("202.131.xxx.106:xxxx", "xxxx", "xxxxx") or die(mysql_error());
Someone here suggests that it might be a firewall problem:
I have just had this problem and found it was my firewall. I use PCTools Firewall Plus and it wasn't allowing full access to MySQL. Once I changed that it was fine.
Could that be it?
Also, someone here suggests that it might be because the MySQL server is bound to the loop-back IP (127.0.0.1 / localhost) which effectively cuts you off from connecting from "outside".
If this is the case, you need to upload the script to the webserver (which is probably also running the MySQL server) and keep your server host as 'localhost'
Open mysql configuration file named my.cnf and try to find "bind-address", here replace the setting (127.0.0.1 OR localhost) with your live server ip (the ip you are using in mysql_connect function)
This will solve the problem definitely.
Allow remote connect to MySQL.
Edit file:
>sudo nano /etc/mysql/my.cnf
Comment line:
#bind-address = 127.0.0.1
Restart MySQL:
>sudo service mysql restart
Create user for remote connection.
>mysql -uroot -p
CREATE USER 'developer'#'localhost' IDENTIFIED BY 'dev_password';
CREATE USER 'developer'#'%' IDENTIFIED BY 'dev_password';
GRANT ALL ON *.* TO 'developer'#'localhost';
GRANT ALL ON *.* TO 'developer'#'%';
In my case I need to connect remotely from Windows to VirtualBox machine with Ubuntu. So I need to allow port 3306 in iptables:
>iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
Had this problem when setting up a new slave server. Found it was the slave server IP address was missing from the master server /etc/hosts.allow file. Added the IP address and it let me connect to the master server.
Note that I use hosts.allow and hosts.deny to control access.
I had this problem and it ended up being the prior sys admin changed the port MySQL was running on. MySQL Workbench was trying to connect to the default 3306 but the server was running on 20300.
The error means that it didn't receive a response from the port it expected to find the server on. The causes range from contacting the wrong machine (For one of a number of reasons) to the server not being on the expected port.
Check which port your server is bound to in /etc/mysql/my.cnf. Does that correspond to what is in your connect statement. If they match then try connecting with mysql from the server itself and from the command line of the machine where you are running the client. If it works form one place and not another then you may have a firewall / router configuration issue.
One more reason...
I ran into an Ubuntu server where everything was customized and could not connect because of that same error.
This setting was inside /etc/ssh/sshd_config
PermitTunnel no
After turning into
PermitTunnel yes
I was able to connect remotely to my MySQL DB
The problem on my case was MySQL being bind only to the lo on linux.
in order to solve the problem i have edited the my.cnf (found at /etc/mysql/my.cnf) removing the line bind-address=127.0.0.1
this allows mysql to bind to any network interface
I just set up mysql on a windows box. I got the OP's error when trying to connect with the Navicat MySql client on the same box. I had to specify 127.0.0.1 as the host, and that got it.
localhost, or the servers actual ip address both did not work.
This error occurred to me while trying to connect to the Google Cloud SQL using MySQL Workbench 6.3.
After a little research I found that my IP address has been changed by the internet provider and he was not allowed in the Cloud SQL.
I authorized it and went back to work.
I faced the same problem. I checked and tried to set AllowTcpForwarding Yes but it was missing in my sshd_config so no help.I didn't change sshd_config or my.cnf. Make sure the ssh hostname is NOT the same with the mysql hostname(use localhost).
In workbench, choose + to add new connection and set the following:
connection method: standard TCP/IP over SSH
SSH Hostname: 192.168.0.50:22 (replace remote SSH server IP and port(optional))
SSH Username: sshuser
You can set password or add at the prompt
MYSQL Hostname: localhost or 127.0.0.1
MYSQL Server port:3306
You can set password or add at the prompt
Test connection. It should be successful then hit OK.Viola!
I ran into this exact same error when connecting from MySQL workbench. Here's how I fixed it. My /etc/my.cnf configuration file had the bind-address value set to the server's IP address. This had to be done to setup replication. Anyway, I solved it by doing two things:
create a user that can be used to connect from the bind address in the my.cnf file
e.g.
CREATE USER 'username'#'bind-address' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON schemaname.* TO 'username'#'bind-address';
FLUSH PRIVILEGES;
change the MySQL hostname value in the connection details in MySQL workbench to match the bind-address
The problem for me was that DNS queries were blocked by the FW within the subnet. The solution was to disable DNS lookups within MySQL.
The problem was quite stupid for me.
I used to get the same issue on AWS EC2 Ubuntu machine (MariaDB is installed locally for the time being), so I tried to make SSH tunneling, and had the same issue. So I tried to ssh tunnel over terminal:
ssh -L13306:127.0.0.1:3306 root#ip.address -i my/private/key.pem
And it told me this:
Please login as the user "ubuntu" rather than the user "root".
I changed ssh user from root to ubuntu, just like my ssh config, and it connected just fine.
So check your SSH connecting user.
I oversaw this, so this too half an hour of my time, so I hope this will be useful for you.
For me the config file was found "/etc/mysql/mysql.conf.d/mysqld.cnf" commenting out bind address did the trick.
As we can see here:
Instead of skip-networking the default is now to listen only on
localhost which is more compatible and is not less secure.
I am trying to connect my db docker container on Ubuntu 18.04, same problem.
First check your device by run nmcli dev to check if device docker0 is connected.
If it is not connected, try to restart docker service:
sudo service docker restart
I tried make a telnet over remote server on port 3306.
The error message is clear
Host 'x.x.x.x' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'Connection closed by foreign host.
As root at server mysqladmin flush-hosts worked at all!
I had the same error when using localhost. I restarted the MySQL service and it worked fine.
in my case, I had ALL: ALL in hosts.deny. Changing this to ALL: PARANOID solved my problem when connecting over ssh
Ran into this same issue, Bind Address back and forth to no avail. Solution for me was flushing privileges.
mysql> FLUSH PRIVILEGES;
Firewalld blocks the IP address. so to give access, use these commands:
firewall-cmd --permanent --zone=trusted --add-source=YOUR_IP/32
firewall-cmd --permanent --zone=trusted --add-port=3306/tcp
firewall-cmd --reload
For me setting bind-address = 0.0.0.0 in mysql/my.cnf worked. It basically listens to all addresses (but still one port) then.
And don't forget restart your server: systemctl restart mysql
I just had the same problem, but in my case I solved it with
service mysqld start
In my case it was the university wifi blocking port 3306. I was able to connect by using a mobile hotspot.
Change to a mobile hotspot or another network, and if it works there, then you know that original network is blocking port 3306. If you get the same error on more than 1 network, then you know it's specific to your machine.
I had port 3306 in Docker container but in Dockerfile it was 33060. I edited the port in Docker container to 33060
Must have been added to the Dockerfile
ENV MYSQL_ROOT_HOST 172.17.0.1
I have done below 3 steps then working for me.
bind-address = "YOUR MACHINE IP" in my.cnf file at /etc/my.cnf
Restart service by command : service mysql restart
GRANT ALL PRIVILEGES ON yourDB.* TO 'username'#'YOUR_APPLICATION_IP' IDENTIFIED BY 'YOUR_PASSWORD' WITH GRANT OPTION;
I had the same issue installing MySQL docker image then trying to connect from WSL2 MySQL client.
As it was stated in the accepted answer that it should be a firewall issue, in my case this error was caused due to not allowing docker for windows to communicate to private network.
I changed the settings on "Firewall & network protection", "allow an app through firewall", "change settings" (need administrator rights) and allowed "Docker desktop backend" to connect to private network.
I had the same error on my Mac with a local MySQL installation. The problem was that the number files that MySQL was opening was too high for MacOS.
To see if you have the same problem you can run this command and look for File Descriptor errors:
tail -200 /usr/local/var/mysql/$(whoami).err | grep "Warning"
I added this line to my.cnf file and the problem was fixed:
table_open_cache = 200
Had the same problem, what worked for me was:
Go to Windows Firewall where you allow applications.
mysql probably won't be in the list, so you need to add it, its path is typically C:/Program Files (x86)/MySQL/bin/mysql
Mark both private and public networks, apply.
When connecting to Mysql remotely, I got the error.
I had this warning in /var/log/mysqld.log:
[Warning] IP address 'X.X.X.X' could not be resolved: Temporary failure in name resolution
I just added this line to /etc/hosts file:
X.X.X.X some_name
Problem solved! Not using skip-name-resolve caused some errors in my local app when connecting to MySQL.

Configuring WL to listen for my IP address

I know how to configure WL to listen for a my IP address instead of localhost. I had done it in past and it worked as well. Today suddenly things are broken, as usual I started my server configured for listening to my IP address and I was not even able to open the WL console.
I thought it could be some proxy issue so I removed all my proxies and then tried but no help. Then just to be double sure I used curl and tried to GET the admin page but still no help.
Then I thought that it could related to some recent firewall blocking rules my company might have pushed so this link and added my port to unblock list for both inbound and unbound rules, but still not help.
Does anyone has any idea whether there is something I can do to debug or rectify this issue. Please note that I have already tried changing my WL listen address to "no address", specific address etc. but it doesn't help, and I have tried netstat -a -n command and I can see there is a connection listening for my IP:port, but in the end I cannot access that connection/socket or in other words I cannot access my WL admin console or my application
I am assuming that your servers and applications are running. But you are not able to access them.
In this case, You can start from here.
1. Verify whether you are able to ping the admin host. If so, see whether telnet is allowed on admin port.
2. Try accessing the console with both FQDN and ip address.
3. If vnc server is configured on your server which is hosting weblogic, try launching chrome from VNC to access weblogic admin console.

Unable to resolve CRM web application url with hostname from outside browsers

I have a deployment created with crm 2016 on-premise.
After installation. I am unable to use the webapplication URL from browsers outside the server.
If I use FQDN NAME-IT IS GETTING RESOLVING and able to access org. Eg:
http://testserver.testserverdom.com/Englishorg
If I use hostname url-it is not resolving and getting blank page. Eg:
http://testserver/EnglishOrg
Again if I add host entry in drivers/etc/hosts file in the outside machine like 10.10.10.10 testserver. Able to resolve and access URL.
I have added hostname(A) entry in DNS. I am still unable to resolve it with hostname.
Server have DHCP Assigned IP Address.
I believe you might be having the DNS issue on client - side (outside of you server) which cannot correctly resolve your testserver.
If you run cmd and there try nslookup testserver- you should see if this is resolved with the correct ip address (according you your hosts file change this should be 10.10.10.10). If this does not -- I believe the problem is in DNS query / response, please make sure your local DNS server is configured correctly and make sure your local DNS server is sending back the response to your client.

Resources