DatabaseCleaner/database_cleaner · error · DatabaseCleaner::Safeguard::Error::UrlNotAllowed
ENV['DATABASE_URL'] is set to a URL that is not on the allow
Error message
ENV['DATABASE_URL'] is set to a URL that is not on the allowlist. Please refer to https://github.com/DatabaseCleaner/database_cleaner#safeguards
What it means
Error "ENV['DATABASE_URL'] is set to a URL that is not on the allowlist. Please refer to https://github.com/DatabaseCleaner/database_cleaner#safeguards" thrown in DatabaseCleaner/database_cleaner.
Source
Thrown at lib/database_cleaner/safeguard.rb:28
end
class ProductionEnv < Error
def initialize(env)
super("ENV['#{env}'] is set to production. Please refer to https://github.com/DatabaseCleaner/database_cleaner#safeguards")
end
end
class UrlNotAllowed < Error
def initialize
super("ENV['DATABASE_URL'] is set to a URL that is not on the allowlist. Please refer to https://github.com/DatabaseCleaner/database_cleaner#safeguards")
end
end
end
class AllowedUrl
def run
return if skip?
raise Error::UrlNotAllowed if database_url_not_allowed?
end
private
def database_url_not_allowed?
!DatabaseCleaner.url_allowlist.any? {|allowed| allowed === ENV['DATABASE_URL'] }
end
def skip?
!DatabaseCleaner.url_allowlist
end
end
class RemoteDatabaseUrl
LOCAL = %w(localhost 127.0.0.1)
def runView on GitHub (pinned to 09b47d03cc)
When it happens
Trigger: Thrown at lib/database_cleaner/safeguard.rb:28 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of DatabaseCleaner/database_cleaner@09b47d03cc (2026-08-23).
Data as JSON: /api/errors/ac3ed2e0f6a2d069.
Report an issue: GitHub.