Skip to content
  • Solutions
    By Role
    • For Developers
    • For Content Managers
    • For Agencies
    • For IT Admins
    • For Web Hosters
    • For Developers
    • For Content Managers
    • For Agencies
    • For IT Admins
    • For Web Hosters
    By Infrastructure
    • Overview
    • AWS
    • Microsoft Azure
    • Alibaba Cloud
    • Google Cloud Platform
    • Vultr
    • Overview
    • AWS
    • Microsoft Azure
    • Alibaba Cloud
    • Google Cloud Platform
    • Vultr
    • Digital Ocean
    • Linode
    • Upcloud
    • Oracle
    • OVH
    • Digital Ocean
    • Linode
    • Upcloud
    • Oracle
    • OVH
  • Product
    • Plesk Features
    • Plesk Editions
    • What’s new
    • Pricing
    • Roadmap
    • Lifecycle Policy
    • Extensions Catalogue
  • Pricing
  • Extensions
    Featured Extensions
    • SocialBee
    • WP Toolkit
    • Sitejet Builder for Plesk
    • SEO Toolkit
    • Joomla! Toolkit
    • Premium Email
    • Email Security
    • SocialBee
    • WP Toolkit
    • Sitejet Builder for Plesk
    • SEO Toolkit
    • Joomla! Toolkit
    • Premium Email
    • Email Security
    Bundles and packs:
    • Business and Collaboration Edition
    • WP pack
    • Hosting pack
    • Power pack
    • Language pack
    • Business and Collaboration Edition
    • WP pack
    • Hosting pack
    • Power pack
    • Language pack

    See all Extensions

  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
  • Pricing
  • Solutions
    • By Role
      • For Developers
      • For Content Managers
      • For Agencies
      • For IT Admins
      • For Web Hosters
    • By Infrastructure
      • Overview
      • Plesk on Amazon Web Services (AWS & Lightsail)
      • Microsoft Azure
      • Alibaba Cloud
      • Google Cloud Platform
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
      • Oracle
      • OVH
  • Products
  • Pricing
  • Extensions
    • Featured Extensions
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Joomla! Toolkit
      • Premium Email
      • Email Security
    • Bundles and packs:
      • Business and Collaboration Edition
      • WP pack
      • Hosting pack
      • Power pack
      • Language pack
      • See all Extensions
  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate Program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
  • Pricing
  • Solutions
    • By Role
      • For Developers
      • For Content Managers
      • For Agencies
      • For IT Admins
      • For Web Hosters
    • By Infrastructure
      • Overview
      • Plesk on Amazon Web Services (AWS & Lightsail)
      • Microsoft Azure
      • Alibaba Cloud
      • Google Cloud Platform
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
      • Oracle
      • OVH
  • Products
  • Pricing
  • Extensions
    • Featured Extensions
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Joomla! Toolkit
      • Premium Email
      • Email Security
    • Bundles and packs:
      • Business and Collaboration Edition
      • WP pack
      • Hosting pack
      • Power pack
      • Language pack
      • See all Extensions
  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate Program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
Plesk 360 login
Free Trial

Knowledge Base

Webmail shows 504 Gateway Time-out or 502 Bad Gateway

 
apacheapache configcentoscloudlinuxhorde

Symptoms

  • Performing some operations after being logged into webmail (or being unable to log into webmail at all) results in one of the following errors:

    504 Gateway Time-out
    502 Bad Gateway

    When importing a mailbox via webmail service, the following error is shown in the browser console:

    Failed to load resource: the server responded with a status of 504 ()

    Connection Error (Failed to reach the server)!

  • The Nginx log file /var/log/nginx/error.log contains error messages that are similar to the following:

    2023/01/07 11:32:42 [error] 12026#0: *1721 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 203.0.113.2, server: webmail.example.com, request: "POST /services/ajax.php/imp/viewPort HTTP/1.1", upstream: "http://203.0.113.1:7080/services/ajax.php/imp/viewPort", host: "webmail.example.com", referrer: "http://webmail.example.com/imp/dynamic.php?page=mailbox"

    2024/03/01 11:32:42 [error] 3156232#0: *6740627 upstream prematurely closed connection while reading response header from upstream, client: 203.0.113.2, server: webmail.example.com, request: "POST /roundcube/?_task=login HTTP/2.0", upstream: "https://203.0.113.1:7081/roundcube/?_task=login", host: "webmail.example.com", referrer: "https://webmail.example.com/roundcube/?_task=login&_err=session"

    2024/03/01 11:32:43 [error] 3156232#0: *6738941 connect() failed (111: Connection refused) while connecting to upstream, client: 203.0.113.2, server: webmail.example.com, request: "POST /?_task=mail&_action=refresh HTTP/2.0", upstream: "https://203.0.113.1:7081/?_task=mail&_action=refresh", host: "webmail.example.com", referrer: "https://webmail.example.com/?_task=mail&_mbox=INBOX"

  • A check on the FcgidIOTimeout value in the Apache config file /etc/httpd/conf.d/fcgid.conf or (/etc/apache2/mods-enabled/fcgid.conf) provides a result that is similar to to the following:

    # grep FcgidIOTimeout /etc/httpd/conf.d/fcgid.conf
    FcgidIOTimeout 45

    # grep FcgidIOTimeout /etc/apache2/mods-enabled/fcgid.conf
    FcgidIOTimeout 45

  • A check on the max_input_time and max_execution_time values in the webmail client configuration files provides results that are similar to the following:

    For Horde: /etc/psa-webmail/horde/horde/php.ini

    # egrep "max_execution_time|max_input_time" /etc/psa-webmail/horde/horde/php.ini
    max_input_time = 60
    max_execution_time = 30

    For RoundCube: /etc/psa-webmail/roundcube/php.ini

    # egrep "max_execution_time|max_input_time" /etc/psa-webmail/roundcube/php.ini
    max_input_time = 60
    max_execution_time = 30

    For Plesk Premium Mail: /usr/local/psa/var/modules/kolab/webmail/php.ini

    # egrep "max_execution_time|max_input_time" /usr/local/psa/var/modules/kolab/webmail/php.ini
    max_input_time = 60
    max_execution_time = 30

Cause

Insufficient timeout values are configured in the web server configuration files and/or within the webmail client configuration files and therefore bigger requests that require more time to be executed are timing out.

Resolution

For Plesk on RHEL / CentOS / CloudLinux

  1. Connect to the server via SSH

  2. Open the corresponding php.ini file of the used webmail client with your favorite command-line text editor and increase max_execution_time and max_input_time as necessary:

    Note: The values correspond to seconds, the recommended value for max_execution_time is 300, the recommended value for max_input_time is 600

    •  For Horde: /etc/psa-webmail/horde/horde/php.ini

      # egrep "max_execution_time|max_input_time" /etc/psa-webmail/horde/horde/php.ini
      max_input_time = 600
      max_execution_time = 300

    • For RoundCube: /etc/psa-webmail/roundcube/php…

Tweet
Share
Share
Email
0 Shares
Read the full article
Related Posts

Your Complete .htaccess Guide: Including .htaccess Basics and More

Read More »

NGINX vs Apache – Which Is the Best Web Server in 2024?

Read More »

Top Web Servers For Linux And Windows

Read More »
Knowledge Base

Websites on Plesk server are slow or show error 500 or PHP mail cannot be sent: ap_pass_brigade failed

Read More »

Can’t access mail: Warning: Inotify instance limit for user exceeded

Read More »

Mail delivery does not work: do not list domain in BOTH mydestination and virtual_mailbox_domains

Read More »

Email header analysis reports SPF failed for localhost IP on mail sent from Plesk hosted mailbox: SPF Authentication : SPF Failed for IP – 127.0.0.1

Read More »

Hosting Wiki

  • Server Redundancy
  • Horde
  • QMAIL
  • Sendmail
  • Bare Metal Server
  • PhpMyAdmin
  • phpPgAdmin
  • Oracle VM Server
  • Server Virtualization Software
  • Windows Server
  • Linux
  • PHP
  • HTTP/3
  • HTTP/2
  • Plesk
  • Lighttpd
  • Apache Tomcat
  • NGINX
  • Apache
  • Web Server
  • DNS Server
  • SSH
  • Email Autoresponder
  • Mailing Lists
  • Email Alias
  • Email Virus Protection
  • Email Forwarding
  • Webmail
  • HTTP
X-twitter Linkedin Youtube Reddit Github
  • Product
  • Login
  • Pricing
  • Editions
  • For Partners
  • Partner Program
  • Contributor Program
  • Affiliate Program
  • Plesk University
  • Company
  • Blog
  • Careers
  • Events
  • About Plesk
  • Our Brand
  • Resources
  • User and Admin guides
  • Help Center
  • Migrate to Plesk
  • Contact Us
  • Hosting Wiki
  • Forum
  • Legal
  • Legal
  • Privacy Policy
  • Imprint

© 2025 WebPros International GmbH

Part of the WebPros®  Family