500 Server Error
Symptoms
When navigating to a Mango page in the browser, the page fails to load and Mango displays a "500 - Server Error" or "Internal Server Error" message. This may affect all pages or only specific pages. In some cases, the Mango API endpoints also return 500 errors, while in other cases only the web UI is affected.
Common Causes
-
Corrupted work directory -- Mango uses a
workdirectory to hold pre-compiled web pages and cached resources for better performance. This directory can become corrupted if the computer is power-cycled or the Mango process is killed without a clean shutdown. When the cached files are invalid, the web server cannot serve pages correctly and returns a 500 error. -
Database connection lost -- If the database server (MySQL, MariaDB, or H2) becomes unavailable or the connection pool is exhausted, Mango cannot retrieve the data needed to render pages. This results in 500 errors on pages that require database queries.
-
Module crash or incompatibility -- A faulty or incompatible module can throw uncaught exceptions during page rendering, causing a 500 error. This is especially common after upgrading Mango core without updating all installed modules to compatible versions.
-
Out of memory (OOM) -- When the JVM runs out of heap space, Mango cannot allocate memory to process requests. This produces 500 errors across all endpoints and may also generate
java.lang.OutOfMemoryErrorentries in the log. -
Corrupted mangoUI-settings -- If the UI settings JSON stored in the database contains invalid data (such as malformed theme colors or missing required fields), the UI bootstrap process fails and produces 500-like errors or blank pages with JavaScript exceptions.
-
Disk full -- If the filesystem where Mango stores its database, logs, or work directory runs out of space, write operations fail and Mango cannot function correctly.
Diagnosis
Step 1: Check the Log File
Open <MA_HOME>/logs/ma.log and look for ERROR entries near the time the 500 error occurred. The log will typically contain a Java stack trace that identifies the root cause.
Look for these patterns:
java.lang.OutOfMemoryError-- The JVM is out of heap space.java.sql.SQLExceptionorConnection refused-- Database connectivity issue.FileNotFoundExceptionorIOExceptionin the work directory path -- Corrupted work directory.NullPointerExceptionorClassNotFoundExceptionin a module package -- Module error.No space left on device-- Disk is full.
Step 2: Check System Resources
Verify the host system has adequate resources:
# Check disk space
df -h
# Check memory usage
free -m
# Check if the Mango process is running and its memory usage
ps aux | grep mango
Step 3: Check the Browser Console
Open the browser developer tools (F12 or Ctrl+Shift+J) and check the Console tab for JavaScript errors. If the error is related to the UI bootstrap (such as $injector:modulerr or theme-related errors), the mangoUI-settings JSON in the database may be corrupted.
Step 4: Test the REST API
Try accessing a simple API endpoint directly to determine if the issue is UI-specific or system-wide:
GET /rest/latest/server/system-info
If the API responds normally but the UI returns 500 errors, the issue is likely in the work directory or UI settings. If the API also fails, the issue is at a deeper level (database, memory, or module).
Solutions
Solution for Corrupted Work Directory
This is the most common cause and the simplest to fix:
- Stop Mango.
- Delete the
workdirectory located at<MA_HOME>/work/. - Start Mango. The work directory will be automatically rebuilt.
Mango will take slightly longer to load pages on the first access after clearing the work directory, as it needs to recompile and cache the web resources.
Solution for Database Connection Issues
- Verify the database server is running and accessible.
- Check the database connection settings in
<MA_HOME>/env.properties. - For H2 databases, ensure no other process has locked the database file.
- For MySQL/MariaDB, test the connection independently:
mysql -h localhost -u mango_user -p mango_database - If the connection pool is exhausted, increase the pool size in
env.properties:db.pool.maxActive=100 - Restart Mango after making configuration changes.
Solution for Module Crashes
- Stop Mango.
- Check
ma.logfor the specific module causing the error (the stack trace will reference the module's Java package). - Remove the problematic module's
.jarfile from<MA_HOME>/web/modules/. - Start Mango and verify the error is resolved.
- Download the correct version of the module from the Mango store and reinstall it.
Solution for Out of Memory
- Increase the JVM heap size in the Mango configuration:
# In env.properties or wrapper configuration
wrapper.java.maxmemory=2048 - Review the number of enabled data points and data sources. A very large number of active points consumes significant memory.
- Check purge settings -- retaining too much historical data in the point value cache can exhaust memory.
- Consider upgrading the server hardware or moving to a machine with more RAM.
Solution for Corrupted UI Settings
If the browser console shows AngularJS bootstrap errors related to themes or settings:
- Access the SQL console. If the main UI is broken, navigate to
/login.htmto access the legacy UI (Mango 3.x), or use an external database client. - Delete the corrupted UI settings:
DELETE FROM jsonData WHERE xid = 'mangoUI-settings' - Restart Mango. Default UI settings will be regenerated.
Solution for Disk Full
- Free disk space by deleting old log files, temporary files, or old backups.
- Run a manual purge of point values if the database has grown too large.
- Move the database or log directory to a larger disk if the current filesystem is too small.
- Restart Mango after freeing adequate space.
Prevention
- Always shut down Mango cleanly using the proper shutdown command or service stop. Never kill the process or power-cycle the machine while Mango is running.
- Monitor disk space on the Mango server. Set up alerts for low disk space conditions.
- Configure JVM heap size appropriately for your workload. A minimum of 1 GB is recommended for most installations, with 2-4 GB for large deployments.
- Keep all modules updated to versions compatible with your Mango core version.
- Set up regular database backups so you can recover quickly from corruption.
- Monitor the
ma.logfile for warning messages that may indicate developing problems before they cause outages.
Related Pages
- Database Corruption — Database issues that may cause internal server errors
- H2 to MySQL Migration — Migrate to a production database to improve stability
- Startup Stuck — Server errors during startup that prevent Mango from loading
- Reporting Bugs — How to report server errors with stack traces and diagnostic logs