Skip to content
  • Contact us: +34 944 58 06 58
  • Plesk Partner Program
  • Roadmap
  • Plesk Lifecycle Policy
  • Blog
  • Contact us
  • Plesk 360
  • Contact us: +34 944 58 06 58
  • Plesk Partner Program
  • Roadmap
  • Plesk Lifecycle Policy
  • Blog
  • Contact us
  • Plesk 360
  • Solutions
    By Role
    • Developers
    • Content Managers
    • Digital Agencies
    • IT Admins
    • Web Hosters
    • Hyperscalers
    • Developers
    • Content Managers
    • Digital Agencies
    • IT Admins
    • Web Hosters
    • Hyperscalers
    By Edition
    • Web Admin Edition
    • Web Pro Edition
    • Web Host Edition
    • Business & Collaboration
    • Plesk WP Edition
    • Web Admin Edition
    • Web Pro Edition
    • Web Host Edition
    • Business & Collaboration
    • Plesk WP Edition
    By Cloud
    • Amazon Web Services
    • Microsoft Azure
    • Alibaba Cloud
    • GCP Marketplace
    • Vultr
    • DigitalOcean
    • Linode
    • UpCloud
    • Amazon Web Services
    • Microsoft Azure
    • Alibaba Cloud
    • GCP Marketplace
    • Vultr
    • DigitalOcean
    • Linode
    • UpCloud
    Partner Program
    Exclusive discounts, benefits and exposure to take your business to the next level
    Become a partner
    • By Role
      • Developers
      • Content Managers
      • Digital Agencies
      • IT Admins
      • Web Hosters
      • Hyperscalers
    • By Edition
      • Web Admin Edition
      • Web Pro Edition
      • Web Host Edition
      • Business & Collaboration
      • WP Edition
    • By Cloud
      • Amazon Web Services
      • Microsoft Azure
      • Alibaba Cloud
      • GCP Marketplace
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
    • Partner Program
      • Partner Program
  • Product
    Explore Features
    • Everyone
    • Admins & Web Hosters
    • Developers
    • Designers & Agencies
    • Plesk Features
    • Roadmap
    • Everyone
    • Admins & Web Hosters
    • Developers
    • Designers & Agencies
    • Plesk Features
    • Roadmap
    Key Topics
    • SocialBee
    • WP Toolkit
    • Sitejet Builder
    • SEO Toolkit
    • Joomla! Toolkit
    • Plesk Premium Email
    • Plesk Email Security
    • SocialBee
    • WP Toolkit
    • Sitejet Builder
    • SEO Toolkit
    • Joomla! Toolkit
    • Plesk Premium Email
    • Plesk Email Security
    Feature Packs
    • Business & Collaboration
    • WP Pack
    • Hosting Pack
    • Power Pack
    • Language Pack
    • Business & Collaboration
    • WP Pack
    • Hosting Pack
    • Power Pack
    • Language Pack
    Featured Extension
    SocialBee
    • Explore Features
      • Everyone
      • Admins & Web Hosters
      • Developers
      • Designers & Agencies
      • Plesk Features
    • Key Topics
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Plesk Premium Email
      • Plesk Email Security
    • Feature Packs
      • Business & Collaboration
      • WP Pack
      • Hosting Pack
      • Power Pack
      • Language Pack
    • Featured Extension
      • Extension
  • Pricing
  • Extensions
  • Help Center
  • More
    • Careers
    • Events
    • Plesk University
  • FREE TRIAL
  • Solutions
    • By Role
      • Developers
      • Content Managers
      • Digital Agencies
      • IT Admins
      • Web Hosters
      • Hyperscalers
    • By Edition
      • Web Admin Edition
      • Web Pro Edition
      • Web Host Edition
      • Business & Collaboration
      • WP Edition
    • By Cloud
      • Amazon Web Services
      • Microsoft Azure
      • Alibaba Cloud
      • GCP Marketplace
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
    • Partner Program
      • Partner Program
  • Product
    • Explore Features
      • Everyone
      • Admins & Web Hosters
      • Developers
      • Designers & Agencies
      • Plesk Features
    • Key Topics
      • SocialBee
      • WP Toolkit
      • Sitejet Builder
      • SEO Toolkit
      • Joomla! Toolkit
      • Plesk Premium Email
      • Plesk Email Security
    • Feature Packs
      • Business & Collaboration
      • WP Pack
      • Hosting Pack
      • Power Pack
      • Language Pack
    • Featured Extension
      • SocialBee
  • Pricing
  • Extensions
  • Help center
  • More
    • Careers
    • Events
    • Plesk University
    • Blog
    • Plesk Partner Program
    • Roadmap
    • Plesk Lifecycle Policy
    • Contact Us
  • FREE TRIAL
  • Solutions
    • By Role
      • Developers
      • Content Managers
      • Digital Agencies
      • IT Admins
      • Web Hosters
      • Hyperscalers
    • By Edition
      • Web Admin Edition
      • Web Pro Edition
      • Web Host Edition
      • Business & Collaboration
      • WP Edition
    • By Cloud
      • Amazon Web Services
      • Microsoft Azure
      • Alibaba Cloud
      • GCP Marketplace
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
    • Partner Program
      • Partner Program
  • Product
    • Explore Features
      • Everyone
      • Admins & Web Hosters
      • Developers
      • Designers & Agencies
      • Plesk Features
    • Key Topics
      • SocialBee
      • WP Toolkit
      • Sitejet Builder
      • SEO Toolkit
      • Joomla! Toolkit
      • Plesk Premium Email
      • Plesk Email Security
    • Feature Packs
      • Business & Collaboration
      • WP Pack
      • Hosting Pack
      • Power Pack
      • Language Pack
    • Featured Extension
      • SocialBee
  • Pricing
  • Extensions
  • Help center
  • More
    • Careers
    • Events
    • Plesk University
    • Blog
    • Plesk Partner Program
    • Roadmap
    • Plesk Lifecycle Policy
    • Contact Us
  • 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

Industry
Partners

industry-partner_ALIBABA
industry-partner_GOOGLEPARTNER
industry-partner_MICROSOFT
industry-partner_REDHAT-r2
industry-partner_ALIBABA
industry-partner_AUTOMATTIC
industry-partner_AWS
industry-partner_DIGITALOCEAN
industry-partner_SCALEWAY
Follow us:
Facebook Twitter Linkedin Youtube Github

COMPANY

About Plesk
Our Brand
Legal
Careers
Impressum

PRODUCT

Pricing 
Extensions
What’s new

KNOWLEDGE BASE

Documentation
Help Center
Migrate to Plesk
Contact Us
Hosting Wiki
Preview releases

PROGRAMS

Contributor Program NEW
Partner Program
Affiliate ProgramNEW

COMMUNITY

Blog
Forums 
Plesk University

First defaul

Company

About Plesk
Our Brand
Legal
Careers
Impressum

PRODUCT

Pricing 
Extensions
What’s new

KNOWLEDGE BASE​

Documentation
Help Center
Migrate to Plesk
Contact Us
Hosting Wiki
Preview releases

PROGRAMS​

Contributor Program NEW
Partner Program
Affiliate ProgramNEW

COMMUNITY​

Blog
Forums
Plesk University

Follow us:
Facebook Twitter Linkedin Youtube Github

© 2025 WebPros International GmbH. All rights reserved. Plesk and the Plesk logo are trademarks of WebPros International GmbH.

Managed with love with Plesk WP Toolkit