php – how to resolve cron wget host address issue-ThrowExceptions

Exception or error:

I have PHP MVC locally. Using vagrant. Setting up cron to get userdata and send mail.
Below is my cron command:

*/2 * * * * wget ""

In /var/mail/vagrant it is giving error as

Resolving ( failed: Name or service not known.
wget: unable to resolve host address ‘’

I tried with curl also:

*/2 * * * * curl --silent ""

Still, it was not executing

When I hit url directly it sends mail. What mistake I am doing that cron in unable to send mail?
How can I debug?

How to solve:

I found the mistake I was doing.
As cron was written in Virtual machine it was unable to know where my site_url is. It was known when ping/curl/wget site_url was not working.

site_url was set only in my windows’ host file but nowhere in virtual machine.
So solution was to update /etc/hosts file in virtual machine so that it will also know where the url is. Using /etc/host it will resolve DNS host issue and in apache conf I had workspace path allocation.
Thanks @ Greg Schmidt

Leave a Reply

Your email address will not be published. Required fields are marked *