Abs
Abs

Reputation: 57966

The server at www.localhost.com is taking too long to respond

A very strange thing is happening. I am running a script on a new server (it works on my current server and laptop).

The strange thing is that I only get it to (sort of) work when I increase memory limit to 1024M (!). It is extracting a large zip file and going through the files, so I thought it was normal. Instead of this script terminating or ending with errors. I get an error from my browser:

The server at www.localhost.com is taking too long to respond.

Localhost.com? The web server is just localhost:9090 and I can see Apache is still running. Maybe Apache crashes momentarily and it can't find the server? But nothing about apache crashing in the log files.

This isn't a server issue, its more to do with my PHP script and memory usage I think, so no need to move to server fault.

What could be the problem? How can I narrow do the cause, I am at loss here!

The server is a windows server running Apache 2.2 with PHP version 5.3.2. May laptop and the other working server are running version 5.3.0 and 5.3.1 for PHP.

Thanks all for any help

Upvotes: 0

Views: 8585

Answers (4)

kfuller
kfuller

Reputation: 11

I kept getting this problem too, and none of these sites really helped until I started looking at the same thing for people using Internet Explorer. The way I fixed it is to open up the system hosts file, located at C:\Windows\System32\drivers\etc\hosts, and then uncomment out the line that mentions ::1, which is needed for IPv6. After that it worked fine.

Upvotes: 1

David Yell
David Yell

Reputation: 11855

Ensure that,

ini_set('display_errors','On');
ini_set('error_reporting',E_ALL);
ini_set('max_execution_time', 180);
ini_set('memory_limit','1024MB' );

I'd pop this in the top of the script and see what comes out. It should show you errors and the like.

The other thing, have you checked fopen and the path of the file which it's loading?

Abs said,

check files being zipped up can be zipped by PHP (permissions especially on a Windows OS with multi users)

Upvotes: 1

Adrian
Adrian

Reputation: 2923

I am not a php guru by any means but are you writing the extracted files to a temporary local storage location that is within the scope of the application? Because if you are not then I think what is happening is that the application is storing the zip file and extracted files in memory and then is attempting to read them. So if it is a large zip and/or the extracted files are large that would introduce a huge amount of overhead on top of the overhead introduced by your read and processing actions.

So if you are not already I would extracted the files and write them to disk in their own folder, dispose of the zip file at this point, and then iterate over the files in your newly created directory and perform whatever actions you need to on them.

Upvotes: 0

Marc B
Marc B

Reputation: 360872

Somehow your system's munged up and isn't treating localhost as the local 127.0.0.1 address. Is your hosts file properly configured? This is most likely why you're getting the "too long to respond" error:

marc@panic:~$ host www.localhost.com
www.localhost.com has address 64.99.64.32

marc@panic:~$ wget www.localhost.com
--2010-08-03 22:41:05--  http://www.localhost.com/
Resolving www.localhost.com... 64.99.64.32
Connecting to www.localhost.com|64.99.64.32|:80... connected.
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.
Retrying.

www.localhost.com is full valid hostname as far as the DNS system is concerned.

Upvotes: 0

Related Questions