95
Jupitor$ bundle exec rake db:create db:migrate
APP_development already exists
rake aborted!
PG::Error: ERROR:  invalid value for parameter "TimeZone": "UTC"
: SET time zone 'UTC'

I keep getting this error when trying to migrate to my postgres database. help would be much appreciated!

5
  • 2
    The command SET time zone 'UTC' works in my PostgreSQL 9.1.4 installation. Jul 10, 2012 at 10:17
  • 1
    What PostgreSQL version are you using? Does SET time zone 'UTC' work in a psql console for you? Jul 10, 2012 at 20:07
  • I'm using 9.1.4 where/how do I enter SET time zone 'UTC'? Jul 11, 2012 at 3:42
  • 1
    Jupitor=# SET time zone 'UTC'; ERROR: invalid value for parameter "TimeZone": "UTC" Jul 11, 2012 at 16:39
  • 1
    Postgres (v.9.2.4) doesn't like UTC, use 'GMT' instead.
    – PhoebeB
    Aug 9, 2013 at 10:58

17 Answers 17

139

I had the same problem using the Postgres.app from Heroku. Rebooting my Mac solved it.

10
  • 2
    Really weird, tried restarting the app and setting the time zone. Neither worked, then rebooted mac and boom, no issues.
    – Steve
    Feb 27, 2013 at 1:26
  • 5
    I had this problem after reinstalling postgress via brew. Restarting mac helped.
    – maicher
    Jun 17, 2015 at 16:20
  • 1
    restarting postgresql after upgrade fixes issue "pg_ctl restart"
    – Jerzyk
    Oct 12, 2015 at 18:51
  • 5
    restarting postgres worked for me as well. My error was ERROR: invalid value for parameter "TimeZone": "America/Chicago" though. Just thought i'd add this comment because I wasted time searching for this error message not realizing that it also happens for UTC
    – Colin D
    Nov 11, 2015 at 3:58
  • 1
    I honestly can't believe it, but this actually worked.
    – Ryan
    Mar 25, 2019 at 20:04
83

Restarting postgresql works.

To restart if you've installed it using homebrew, brew info postgresql will tell you to:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
4
  • 8
    That's right, this happens because PostgreSQL was upgraded but not restarted.
    – Fred
    Apr 14, 2014 at 8:14
  • Thanks, I would have been surprised if a reboot had really been the only answer.
    – sirdharma
    Jun 12, 2015 at 0:05
  • 7
    for brew you can restart even easier with brew services restart postgresql or if you use a specific version, something like brew servces restart [email protected] Jan 14, 2019 at 15:05
  • If I could upvote this again, I would. Just ran into this error a second time, went searching, and found this link was purple. Restarting postgres solved it for me again.
    – Kingdon
    Jun 5, 2020 at 20:13
25

brew services restart postgresql

15

Try restarting the server. I updated Postgresql through Homebrew but forgot to restart the server and got this same problem. I believe it's due to the client and server versions not matching. psql started with:

$ psql
psql (9.1.4, server 9.1.2)
Type "help" for help.
14

Based on @MathiasJ's answer, instead of rebooting my entire machine, I ran

brew services restart [email protected]

and my subsequent rake db:create worked perfectly.

1
  • 2
    This tip saved me a reboot. Thanks! Nov 22, 2019 at 16:01
8

I don't think I deserve any points for that but rebooting my Postgres.app (which is better than rebooting the whole system) solved it for me. The app doesn't show up on the Dock, you can find it on the navbar at the top of your window. Hope it helps anyway.

5

What actually happened is that you upgraded the postgresql server and cleaned-up your old folders but you haven't restarted your postgresql server. The server searched for the timezones files in the deleted dir

5

If nothing else fixes and you happen to be using homebrew, chances are you have issues with current links.

Assuming you have two Postgres versions installed, make sure you unlink and then link again. In my case, I needed the two versions working in order to run pg_upgrade. I have postgresql95 and postgresql so I did:

$ brew unlink postgresql
$ brew unlink postgresql95
$ brew link postgresql95
$ brew link --overwrite postgresql 

That got me both working at same time. Hope it becomes helpful as it took me a good while to figure that out!

4

I also had this problem.

Login to the database then issue:

set time zone utc;
1
  • 24
    Didn't work for me. ERROR: invalid value for parameter "TimeZone": "utc" Dec 4, 2012 at 16:51
3

In my case restarting the database didn't help. Updating tzdata (apt-get install tzdata) did the trick for me.

0
3

brew services restart postgresql did not fix for me. I'm sure rebooting would've worked, but I wanted to figure out the cause of the issue.


I believe the issue was caused for me because of two conflicting versions of postgresql.

I already had postgresql running with brew services, and then installed postgresql@11 which left postgresql running in brew services even after I uninstalled postgresql.

I fixed this by stopping the postgresql brew service, even though it wasn't listed in brew services list.


Steps to reproduce:

$ brew install postgresql
$ brew services start postgresql

$ brew install postgresql@11
$ brew uninstall postgresql

$ brew services start postgresql@11

How to fix:

$ brew services stop postgresql

Update: issue appears to have been deleted.

Opened an issue on Homebrew requesting that a formula's service should automatically be stopped upon uninstall.

2
  • My problem was I had [email protected] running, then installed [email protected]. Even though I'd uninstalled 9.5, it was still running. Restarting 9.6 didn't fix it. The actual fix was to stop 9.5, and then restart 9.6, and then this worked. Nov 28, 2019 at 0:20
  • Uninstalling all postgresql could make this even worse.
    – theKid
    Aug 26, 2020 at 20:55
2

just restarting the database helped. Homebrew updated my Postgres installation and I did not restart yet.

2

I had a similar problem after updating time zone information, that is, downloading the IANA database and compiling using zic.

My problem actually began after restarting PostgreSQL. I got invalid value for parameter TimeZone: UTC and restarting again did nothing to solve the problem.

It turns out my time zone information was completely messed up after the update. I had dangling symbolic links in /usr/share/zoneinfo. From a psql console, I got:

mydb=# SELECT * FROM pg_timezone_names;
ERROR:  could not stat "/usr/share/zoneinfo/PRC": No such file or directory

I deleted all such dangling symlinks. After doing this, at least I could get SELECT * FROM pg_timezone_names to work, but still got the same invalid value... error.

What finally solved the problem for me was creating a new symlink:

cd /usr/share/zoneinfo
ln -s Etc/UTC UTC

After this, SET time zone 'UTC' worked correctly.

1

Just a quick reference for those that are not using Postgres.app, but that start psql from the command line or through launchctl. You'll need to adjust the following for where you have your Postgres data and log files located at:

pg_ctl stop
pg_ctl start -D /usr/local/pgsql/data/ -l /usr/local/pgsql/log/server.log
1
  • I did exactly this. I'm used to start/stop postgres from the terminal on Mac and this worked just fine Nov 29, 2017 at 23:39
1

For everyone using homebrew.

brew services restart postgresql did not fix for me too.

Rebooting fixed the issue. Thank you @JBallin, what you said is right.

0

Apparently, a similar thing also happens with Java/JDBC while connecting to Postgres.

The solution there is to tell JDBC to report the correct user timezone to Postgres while getting the connection.

So, explicitly mention the user timezone while starting the program helps:

java -Duser.timezone=America/Los_Angeles com.example.MyMainClass

Note:

Adding this here because this happens to be the first result on Google for this issue with connecting to Postgres!

Source:

This comment by Yuriy on the Jira support forum: https://community.atlassian.com/t5/Jira-questions/invalid-value-for-parameter-quot-TimeZone-quot-quot-US-Pacific/qaq-p/839426

0

I had a similar problem on Ubuntu 22 with postgres 13 installed.

SELECT name FROM pg_timezone_names;

Returned empty results.

Figured out it was a permission issue.

the timezone folder under postgres installation (../share/timezone/) had a few files without proper permissions for the user running the database.

Once the required read permission was provided the problem was resolved.

psql=# SELECT name FROM pg_timezone_names;
               name               
----------------------------------
 Pacific/Tahiti
 Pacific/Midway
 Pacific/Pitcairn
 Pacific/Yap
 Pacific/Truk
 Pacific/Galapagos
 Pacific/Tongatapu
 Pacific/Bougainville
 Pacific/Auckland
 Pacific/Saipan
 Pacific/Noumea

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.