400 Bad Request error on email settings page,

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can. :heart:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 31.0.6
  • Operating system and version (e.g., Ubuntu 24.04):
    • 22.04
  • Web server and version (e.g, Apache 2.4.25):
    • `Apache/2.4.58
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • None
  • PHP version (e.g, 8.3):
    • 8.2
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • Immediately after a fresh installation, on the first attempt to configure the email server. The error has persisted even after a complete server OS and Nextcloud application re-installation.
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Manual install from official .zip archive on a standard LAMP stack.
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

Persistent AxiosError: Request failed with status code 400 when I click “Send email” in the Administration > Basic settings.

This error is happening on a second, completely new server from Hetzner with a fresh, stable Nextcloud installation. The error still appeared on the previous installation, hence why I restarted from scratch.

The error is completely silent in all logs. Nothing appears in nextcloud.log or the Apache error.log when the 400 error occurs in the browser.

  • The server was completely rebuilt with a fresh Ubuntu 22.04 OS.
  • The Nextcloud installation is a fresh download of the latest.zip.
  • DNS (from OVH) is pointing correctly to the new server IP.
  • The Apache configuration was built from scratch and is correct (with AllowOverride All).
  • The SSL certificate (from Let’s Encrypt/Certbot) is working correctly.
  • Nextcloud’s config.php file is correct (trusted_domains, overwrite protocols are all set).
  • The .htaccess file is correct and we have proven Apache is reading it (it throws a 500 error if we add garbage to it).
  • mod_security is not installed.
  • The issue persists in a private/incognito browser window.
  • A simple, independent test.php script can successfully process a POST request, so the basic PHP/Apache environment is functional.

Steps to replicate it (hint: details matter!):

  • Provision a new, clean server instance on Hetzner with the Ubuntu 22.04 image.
  • Perform a manual installation of a standard LAMP stack (Apache, MySQL, PHP 8.2 with all required extensions).
  • Download the latest.zip from Nextcloud’s official site and perform a fresh installation (resulted in version 31.0.6).
  • Complete the web setup wizard successfully.
  • Navigate to Administration settings -> Basic settings -> Email server.
  • Fill in any valid SMTP credentials and click the “Send email” button.
  • The browser immediately receives a 400 Bad Request error.

Log entries

Nextcloud

Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the Copy raw option from Administration settings->Logging screen or from your nextcloud.log located in your data directory). Feel free to use a pastebin/gist service if necessary.

**No log entries are generated in `nextcloud.log` when the `400` error occurs.**

Web Browser

If the problem is related to the Web interface, open your browser inspector Console and Network tabs while refreshing (reloading) and reproducing the problem. Provide any relevant output/errors here that appear.

AxiosError: Request failed with status code 400

Web server / Reverse Proxy

The output of your Apache/nginx/system log in /var/log/____:

No log entries are generated in the Apache error.log when the 400 error occurs.

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'REDACTED',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'default_phone_region' => 'FR',
  'trusted_domains' => 
  array (
    0 => 'domain',
    1 => 'www.domain',
    2 => 'domain_ip',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '31.0.6.2',
  'overwrite.cli.url' => 'https://domain',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'REDACTED',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => [
    'host' => 'localhost',
    'port' => 6379,
  ],
);

Apps

Enabled:

  • activity: 4.0.0
  • app_api: 5.0.2
  • bruteforcesettings: 4.0.0
  • circles: 31.0.0
  • cloud_federation_api: 1.14.0
  • comments: 1.21.0
  • contactsinteraction: 1.12.0
  • dashboard: 7.11.0
  • dav: 1.33.0
  • federatedfilesharing: 1.21.0
  • federation: 1.21.0
  • files: 2.3.1
  • files_downloadlimit: 4.0.0
  • files_pdfviewer: 4.0.0
  • files_reminders: 1.4.0
  • files_sharing: 1.23.1
  • files_trashbin: 1.21.0
  • files_versions: 1.24.0
  • firstrunwizard: 4.0.0
  • logreader: 4.0.0
  • lookup_server_connector: 1.19.0
  • nextcloud_announcements: 3.0.0
  • notifications: 4.0.0
  • oauth2: 1.19.1
  • password_policy: 3.0.0
  • photos: 4.0.0-dev.1
  • privacy: 3.0.0
  • profile: 1.0.0
  • provisioning_api: 1.21.0
  • recommendations: 4.0.0
  • registration: 2.7.0
  • related_resources: 2.0.0
  • richdocumentscode: 25.4.202
  • serverinfo: 3.0.0
  • settings: 1.14.0
  • sharebymail: 1.21.0
  • spreed: 21.1.0
  • support: 3.0.0
  • survey_client: 3.0.0
  • systemtags: 1.21.1
  • text: 5.0.0
  • theming: 2.6.1
  • twofactor_backupcodes: 1.20.0
  • updatenotification: 1.21.0
  • user_status: 1.11.0
  • viewer: 4.0.0
  • weather_status: 1.11.0
  • webhook_listeners: 1.2.0
  • workflowengine: 2.13.0
    Disabled:
  • admin_audit: 1.21.0
  • encryption: 2.19.0
  • files_external: 1.23.0
  • suspicious_login: 9.0.1
  • twofactor_nextcloud_notification: 5.0.0
  • twofactor_totp: 13.0.0-dev.0
  • user_ldap: 1.22.0

First set up admin account’s e-mail address, i think.

Thank you for trying to help. I spent 7h trying to figure out the solution to my problem. However the only thing blocking me from sending emails was my cloud server provider which blocks port 465 by default (to prevent email scams). I sent a request to unblock but in the meantime i’ll just use port 587.

So to anyone passing by, make sure your cloud server has the correct ports unblocked!!!

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.