Explain Codes LogoExplain Codes Logo

Server returns invalid timezone. Go to Advanced tab and set servertimezone property manually

sql
database-connections
timezone-configuration
intellij-settings
Anton ShumikhinbyAnton Shumikhin·Mar 6, 2025
TLDR

To fix the timezone issue, append ?serverTimezone=YourTimeZone at the end of your SQL connection URL, like so:

jdbc:mysql://host:port/database?serverTimezone=UTC

You must replace YourTimeZone with your actual timezone, say UTC, Europe/Berlin, or America/Los_Angeles, to match your server's timezone setting and evade the error.

Detailed explanation & fixes

Diagnosing Connection Issues

Given a timezone error with database connections in IntelliJ or akin IDE, always check the data source properties meticulously. The serverTimezone parameter should match your intended timezone. When the IDE prompts the manual setting of serverTimezone, do so. Specifically, insert the server's timezone in one of these formats:

  • serverTimezone=UTC
  • serverTimezone=Europe/Berlin
  • serverTimezone=America/Los_Angeles

In case your server disagrees with the system's default timezone, tweak the serverTimezone from the Advanced settings of your connection.

Verifying Compatibility

After setting the serverTimezone, make sure the settings are compatible between IntelliJ and your database such as MySQL Workbench. If not, unwanted behavior may occur. Always remember to restart the database connection after adjusting the serverTimezone property to deploy the changes.

Applying Global Changes

If necessary, you can set the timezone globally in MySQL:

SET GLOBAL time_zone = '+8:00'; // Fellow coders, don't forget to replace '+8:00' with your timezone 😉🕰️

Preventing errors in Data Source Properties

Avoid typos when configuring serverTimezone: they may create additional issues. Always double-check your input and don't forget to click 'Apply' after making changes in DataGrip or the like.

Additional Steps

Now, go to Advanced Settings and set servertimezone:

⚙️ Advanced Tab → servertimezone: 'UTC' ✅

You're all set!

🤖💬 Before: "What's the time again? 🤔" 👩‍💻🛠️ After: "All synced up with UTC! 🌍⏱️"

Extra: Common Environmental Adjustments

Sometimes a persistent IDE prompt becomes quite annoying. Try adjusting the global timezone as a last-resort fix.

The Perfect ‘Cargo Checklist’ for Timezone Configuration

Before we move ahead, here's a pro-tip: Double-checking can never be overstated, especially with critical configuration parameters like serverTimezone.

  1. Right-Click on your database source.
  2. Choose Properties.
  3. Head over to the Advanced tab.
  4. Find and fine-tune serverTimezone.
  5. Press Apply and take a breath! You did it. 🙌
  6. Retest the connection.

Getting into the Nitty-Gritty Details

There are other preventive tips to evade these issues:

  • Regularly check your server's timezone settings, especially when operating across different regions.
  • Ensure there's a matching timezone configuration in your development tools and servers.
  • Issue a routine update of your configurations if daylight saving adjustments result in changed server time settings.

And if you're feeling information-starved:

  • Head over to the official IntelliJ documentation.
  • Engage with the coder community on forums dealing with timezone configurations.