Resource Usage & CloudLinux Limits

Resolving Script Execution Timeouts in Shared Hosting Environments

By the Domain India teamPublished 9 min read
Knowledge base article
Contents (7 sections)

A script timeout happens when a PHP page runs longer than something in the chain is willing to wait. On shared hosting that is common with imports, exports, reports and calls to slow outside services. This guide explains which limit you are hitting on Domain India hosting, why raising max_execution_time often changes nothing, and how to restructure long work so it finishes.

Key takeaways

On our cPanel servers, nginx waits about 90 seconds for a page and then returns a 504 Gateway Timeout, whatever PHP's own limit says, so raising max_execution_time does not help beyond that. Make each web request short: process work in batches, add timeouts to outside calls, and fix slow queries. Move genuinely long jobs to a cron job (the shortest interval on our shared servers is every 4 minutes) or to a VPS where you set the timeouts yourself.

1. Which limit are you hitting?

A web request passes through several layers, and each has its own clock. The error you see tells you which one ran out.

What you seeWhich limitWhere it applies
504 Gateway Timeout after about 90 secondsnginx waiting for the pagecPanel servers
"Maximum execution time of N seconds exceeded"PHP max_execution_timeAny server
Blank page or 500 with a fatal error in the logPHP stopped by a limit or an errorAny server
508 Resource Limit Is ReachedToo many PHP requests at onceShared hosting accounts

The measured values on our shared servers (24 September 2026):

  • cPanel: nginx sits in front of Apache and waits about 90 seconds for a reply. The default PHP max_execution_time is 120 seconds, so on a web request the 90-second nginx limit is the one you hit first.
  • DirectAdmin: there is no nginx layer. The default PHP max_execution_time in the server's PHP builds is 30 seconds.
  • Command-line PHP (cron jobs) has no execution time limit by default, but your plan's CPU and memory limits still apply.

2. Why raising max_execution_time rarely fixes it

On cPanel, a request that runs longer than about 90 seconds gets a 504 from nginx even if PHP would keep going. Raising max_execution_time to 300 changes nothing for the visitor, and the nginx timeout is server-wide, so it can't be changed for one account.

On DirectAdmin, raising the PHP limit may let a slow request finish, but it only hides the problem: a request that takes minutes also holds one of your account's PHP process slots the whole time. A few of those at once and visitors start getting 508 errors. See understanding hosting resource limits.

If you still need to change PHP settings for other reasons, cPanel's MultiPHP INI Editor is covered in how to edit php.ini in cPanel. Don't put php_value lines in .htaccess: PHP does not run as an Apache module on our servers, and those lines cause a 500 error.

3. Find the slow part

Measure before you change anything. Add timing to the script and write it to a log file outside your web folder:

php
<?php
$start = microtime(true);
error_log('job started', 3, __DIR__ . '/../logs/job.log');

$t = microtime(true);
$result = $db->query($sql);
error_log(sprintf("query took %.2fs\n", microtime(true) - $t), 3, __DIR__ . '/../logs/job.log');

error_log(sprintf("total %.2fs\n", microtime(true) - $start), 3, __DIR__ . '/../logs/job.log');

Then read the error log for the time of the failure; see reviewing error logs in cPanel and DirectAdmin. The usual culprits are one slow query, one slow outside API call, or a loop over far more rows than you expected.

4. Make each request shorter

Fix slow queries
Select only the columns you need, add indexes on the columns in WHERE and JOIN clauses, and use LIMIT. One missing index can turn a 50 ms query into 50 seconds.
Put timeouts on outside calls
Payment, shipping, SMS and licence APIs can hang. Give every outbound request a timeout of a few seconds so one slow service can't hold your page.
Process in batches
Handle 200 rows per request instead of 20,000, and save where you stopped. The next request or cron run continues from there.
Cache expensive results
Store a finished report or API response in a file or database table and reuse it until it is out of date, instead of rebuilding it for every visitor.

A batch loop that resumes where it stopped looks like this:

php
<?php
// process up to 200 pending rows per run, then stop
$rows = $db->query("SELECT id, email FROM jobs WHERE status = 'pending' ORDER BY id LIMIT 200");
foreach ($rows as $row) {
    process($row);
    $db->prepare("UPDATE jobs SET status = 'done' WHERE id = ?")->execute([$row['id']]);
}

For outside calls with PHP's HTTP stream functions, set the timeout explicitly:

php
<?php
$ctx = stream_context_create(['http' => ['timeout' => 5]]);
$response = @file_get_contents('https://api.example.com/rates', false, $ctx);
if ($response === false) {
    error_log('rates API did not answer in 5s');
}

Several PHP functions are disabled on our shared servers, including exec, proc_open and, on most DirectAdmin sites, curl_exec. Check PHP disabled functions on shared hosting before you rely on one.

5. Move long work out of the browser

Some jobs are long by nature: a large import, a newsletter batch, a nightly report. Don't run them from a web page at all.

  1. Queue the work.
    When a user starts the job, write a row to a jobs table with status pending and return a page straight away ("Your import has started").
  2. Process it from cron.
    A cron job picks up pending rows, works through a batch, and marks them done. Command-line PHP is not subject to the nginx timeout.
  3. Show progress.
    The web page reads the job's status from the table, so the user can check back.
Cron runs at most every 4 minutes on shared hosting

On our cPanel and DirectAdmin shared servers, jobs set to run every 1, 2 or 3 minutes are changed to every 4 minutes automatically. Size each batch so it finishes well inside 4 minutes, or runs will overlap. Setup steps are in how to set up a cron job.

There is no Redis or other queue service on shared hosting, so a database table is the simplest queue. If the work must run continuously, needs a worker that stays running, or needs its own timeouts, it belongs on a VPS.

6. When a VPS is the right answer

On a VPS you control every layer, so you can set nginx's proxy_read_timeout, Apache's Timeout, PHP-FPM's request_terminate_timeout and PHP's max_execution_time to suit your application, and run queue workers under a process manager. Keep the front layer's timeout slightly longer than the one behind it, so errors come from PHP with a clear message rather than a bare 504.

A Domain India VPS is self-managed: you get full root access and look after the operating system, security and software yourself. Try the steps above first; most timeout problems are fixed by shorter requests, not bigger servers.

7. Where Domain India fits

For PHP sites that do their heavy work in batches and cron jobs, shared hosting is enough. For long-running workers and custom timeouts, choose a VPS.

cPanel Growth
₹200/mo + GST
  • 50 GB NVMe SSD Storage
  • 100 GB Monthly Bandwidth
  • 5 Websites
  • 50 Email Accounts
See plan details
VPS Starter
₹552.65/mo + GST
  • 1 vCPU
  • 2 GB DDR4 RAM
  • 64 GB NVMe SSD Storage
  • 2 TB Monthly Bandwidth
See plan details

Cards show Domain India list prices on 19 September 2026, excluding 18% GST. For WordPress-specific errors, see resolving common gateway errors in WordPress.

Why do I get a 504 Gateway Timeout on cPanel hosting?

On Domain India cPanel servers, nginx waits about 90 seconds for a page. A request that runs longer returns a 504, even if PHP's own time limit is higher. Make the request shorter or move the work to a cron job.

Will increasing max_execution_time fix a 504 error?

No. The 90-second nginx limit on our cPanel servers applies whatever PHP's limit is, and it can't be changed for one account. Split the work into batches, add timeouts to outside calls, or run the job from cron.

What is the default max_execution_time on Domain India hosting?

On our cPanel servers the default is 120 seconds, although web requests are cut off by nginx after about 90 seconds. On our DirectAdmin server the default in the PHP builds is 30 seconds. Command-line PHP used by cron jobs has no time limit by default.

How do I run a script that takes longer than 90 seconds?

Run it from a cron job instead of a web page, or split it into batches that each finish quickly and resume where the last one stopped. Cron on our shared servers runs at most every 4 minutes. For work that must run continuously, use a VPS.

Can I run a queue worker on shared hosting?

Not as a permanent process. Shared hosting has no Redis and no long-running workers. Use a database table as a queue and process it in batches from cron, or move the worker to a VPS.

Can support raise the timeout for my account?

The nginx timeout on our cPanel servers is server-wide and is not changed per account. You can adjust PHP settings in your control panel, but the lasting fix is to make each request shorter or move long work to cron or a VPS.

Ready to fix it? Time the slow part, split the work into batches, and move long jobs to a cron job. If your application needs its own timeouts or workers, compare VPS plans, or open a support ticket with the page, the error and the time it happened.

Need your own timeouts?

Full root access on a KVM VPS, so you set the web server and PHP limits your application needs.

See VPS plans

Ready when you are

Get DirectAdmin hosting from ₹100/mo + GST

See plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app
Fix PHP Script Timeouts and 504 Errors on Shared Hosting