I've searched for this issue but couldn't get any solution working from the client side.

We've mysql server with Apache on Ubuntu.

Our client (MacOS) is getting "can't get hostname for your address" error when connecting to our database. He is able to connect without any problems from Home network but not from his work network.

None of our other clients face this issue so I guess there is no problem on server side. Solutions like editing my.ini or my.cnf is not what we're looking for as server side changes are not encouraged. Any help towards solving this problem will be appreciated.

Server: mysql (Apache,Ubuntu)
Client: macOS


  • I did not understand well which of your clients can connect and which cannot. Are you saying that MacOS clients cannot connect while other (e.g. Windows, Linux) clients can or do you see the majority of your MacOS clients being able to connect and just one specific one cannot? – TorstenS Apr 4 '19 at 9:09
  • @TorstenS Just one MacOS client. – Axel Apr 4 '19 at 9:20
  • is your client able to resolve hostname or is the client able to access db with the ip ? can he ping the hostname or ip ? can he telnet mysql port from work network ? – errorfetch Apr 4 '19 at 11:43

When you say the client in question

is able to connect without any problems from Home network but not from his work network

then I assume it will get assigned a different IP address when connected to the office network versus when connected via VPN from home.

Getting a hostname for an address is nothing but reverse DNS, i.e. first of all, find out which IP address the machine is assigned in the office network and in the home network, see: https://apple.stackexchange.com/questions/20547/how-do-i-find-my-ip-address-from-the-command-line.

Then try an


using either address and check if a hostname is being reported or not. I'd bet in case of the office network, it will come back with NXDOMAIN.

Then the next question is why. That means you will have to check how IP is resolved to names on your network. This can either be a local hosts file or some DHCP/DNS server on your network which doesn't know the name for an IP it's given out.

| improve this answer | |
  • Just to be on the same point, I'm repeating what I understood from your answer: Client is making a connection to mysql server from a different IP for which there is no reverse DNS record on the server. But the client will be making connection from dynamic IP, so how can we make a DNS entry for every IP? – Axel Apr 4 '19 at 10:59
  • Are we talking about internal or public IP addresses? I mean, when connecting from home, is that a VPN or is the MySQL server publicly available over the Internet? – TorstenS Apr 4 '19 at 12:08
  • MySQL server is publicly available over the Internet. – Axel Apr 4 '19 at 12:26

In my case, I try everything available on the Internet but nothing works for me. So I try to solve this problem by changing the name of the computer (B2 to BBB), which changes the numeric value from the Hostname of a computer and finally my problem is solved.

| improve this answer | |
  • Thanks for participating in the site! Welcome to Serverfault, Happy New Year! – Citizen Dec 31 '19 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.