That's what they invented the hosts file for. It could very well be that the gethostbyname() function uses that internally.
Otherwise, you have to write your own code to replace the gethostbyname() function in your development environment. That's how we overcome these limitations.
For example. You write a custom function mygethostbyname(). If it "sees" it's in the development environment it returns the right value. if it's in the productionenvironment if calls gethostbyname().