Free tools Windows power users keep installed
One-click scans. No signup required.
iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
PG::ConnectionBad: connection refused is usually an endpoint or PostgreSQL listener problem, not a bad password. Rails attempted to reach the host, port, or Unix socket shown in the exception and found no server accepting connections there. Start by preserving that endpoint, test it directly with pg_isready, then correct the production DATABASE_URL, database attachment, listener, firewall, or TLS settings. Run migrations only after the database accepts connections.
What “connection refused” means in a Rails deployment
PostgreSQL uses the error when a client cannot find a server to talk to at the requested TCP endpoint or Unix socket. “Connection refused” does not mean PostgreSQL received the request and rejected the credentials. Authentication has not been reached yet.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
The exception normally contains the most useful first clue:
- Hostname or IP address: the machine Rails tried to contact.
- Port: normally
5432, unless your provider or server uses another port. - Socket path: a local Unix-socket directory when no TCP host was selected.
A refused TCP connection generally means that no PostgreSQL process is listening at that host and port, PostgreSQL is listening only on another interface, the port is wrong, the service is still starting, or your app has the wrong network address. A local socket error such as “No such file or directory” points to a missing or inaccessible socket rather than a remote firewall response.
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
Diagnose the exact endpoint before changing credentials
1. Copy the host, port, and socket from the exception
Do not begin by rotating the database password. Save the complete error line and identify whether Rails is trying a hostname, an IP address, localhost, 127.0.0.1, or a Unix socket. A production error that names localhost is a strong sign that the deployment did not receive its managed database URL or that the configuration still points to a local development database.
2. Probe the same endpoint with pg_isready
Run the check from the application environment, or from a machine that has the same network path to the database:
Recommended Free Tools
pg_isready -h HOST -p PORT
Replace HOST and PORT with the values printed by Rails. If the error names a Unix socket, use the socket directory instead:
pg_isready -h /path/to/socket-directory -p 5432
Interpret the result using PostgreSQL’s documented exit statuses:
| Result | Meaning | Next action |
|---|---|---|
| Exit status 0 | The server is accepting connections. | Move to Rails URL, credentials, SSL, or database-name checks. |
| Exit status 1 | The server is reachable but rejecting connections, commonly while starting. | Wait for startup, inspect database logs, and retry. |
| Exit status 2 | No response was received. | Check hostname, port, routing, firewall rules, and whether the service is running. |
A successful probe does not prove that Rails is configured correctly; it proves only that PostgreSQL answers at the endpoint you tested. Test the exact host and port from the exception, not a different local database.
Check the production Rails configuration
Inspect DATABASE_URL safely
In the production service’s environment settings, confirm that DATABASE_URL exists and has the expected scheme, host, port, database name, username, and any required SSL parameters. Inspect its presence and shape without printing the password into build logs. A safe diagnostic can report whether the variable is set and display only the scheme and hostname.
Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
Rails merges DATABASE_URL with config/database.yml. When the URL is present, its adapter and database values cannot be replaced by values in database.yml. Consequently, editing the YAML file will not fix an incorrect host embedded in the environment URL.
Recognize the localhost fallback
If DATABASE_URL is missing, Rails commonly falls back to the defaults in config/database.yml. Typical development defaults use a local PostgreSQL server, localhost, or a Unix socket. That works on a developer laptop but fails in a container or hosted web service where no database process runs inside the web instance.
Set the production URL in the platform’s environment or secret manager, redeploy, and then verify that the exception names the managed database host rather than localhost. Keep development and production settings separate; do not commit a production password to the repository.
Verify the PostgreSQL driver and URL syntax
Include the pg gem
A PostgreSQL-backed Rails application needs the pg gem in its Gemfile, in the groups installed by the deployment:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →gem "pg"
Run the bundle install step used by your platform and confirm that the resulting bundle contains the same major driver version used in the build. A missing driver normally produces an adapter or load error rather than a refused socket, but correcting it prevents a second failure after connectivity is restored.
Validate the connection URL
A PostgreSQL URL generally follows this shape:
postgresql://USERNAME:PASSWORD@HOST:PORT/DATABASE_NAME
Check each component against the provider’s connection string. URL-encode reserved characters in usernames or passwords; an unescaped @, :, or slash can make Rails parse the wrong host or credentials. Preserve provider-supplied query parameters such as sslmode=require when TLS is mandatory. Do not replace a provider hostname with an internal or local address unless the platform documentation specifically requires it.
Rank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
Fix a self-hosted PostgreSQL listener
Confirm that the service is running
On the database server, check the PostgreSQL service status using the service manager for your operating system. If it is stopped, start it and inspect its logs for startup failures, disk exhaustion, invalid configuration, or an occupied port. A service that is still starting can return pg_isready status 1 until recovery completes.
Check the port and listening interfaces
PostgreSQL’s default TCP port is 5432. Confirm the actual port in postgresql.conf and compare it with the Rails URL. PostgreSQL defaults listen_addresses to localhost, which permits loopback connections only. A remote Rails process therefore cannot connect until PostgreSQL listens on a reachable interface, such as the server’s private network address.
Changing listen_addresses to a broad wildcard may expose the database unnecessarily. Prefer the smallest private interface or network required by the application, and restrict inbound access with a firewall or security-group rule. Verify that the rule permits the app’s egress address on the configured port.
Review pg_hba.conf after the listener responds
pg_hba.conf controls which clients may authenticate. It matters after the server is reachable. A host-based authentication rejection usually produces a different error from “connection refused,” so do not treat an pg_hba.conf edit as a substitute for fixing a stopped service, wrong port, or blocked route.
After changing settings that PostgreSQL reads at server start, restart the service according to your operating system’s procedure. Re-run pg_isready from the application network and then try a real Rails connection.
Provider-specific fixes
Render
- Create or select the Render Postgres database and copy its connection string intended for the web service.
- Open the web service’s environment settings and set
DATABASE_URLto that string. Do not paste the password into source control or a public build log. - Provide
RAILS_MASTER_KEYwhen the application uses encrypted credentials that require it during build or boot. - Configure the service’s build or pre-deploy command to run Rails migrations, for example
bin/rails db:migrate, only after the database URL is available. - Redeploy and inspect the new exception, if any. It should name the Render database endpoint rather than a local socket.
The database connection string and migration hook are separate concerns: the first makes the server reachable, while the second changes schema after connectivity works.
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
Heroku
- Attach the Heroku Postgres database to the same application that runs Rails.
- Use the connection configuration supplied to the app instead of a manually typed localhost URL.
- Ensure the
pggem is installed in the deployed bundle. - Retain the TLS settings required by Heroku Postgres. Heroku’s current connection documentation requires TLS 1.2 or higher; some clients need
sslmode=requirein the URL. - Run migrations through the release process after the app can reach the attached database.
A Heroku deployment can therefore fail even when the hostname is correct if the client negotiates an unsupported or disabled TLS mode. Conversely, TLS changes cannot repair a URL that still points to localhost.
Fly.io
- Attach Managed Postgres to the Fly.io application following the platform’s database-attachment flow.
- Confirm that the attachment stores the resulting
DATABASE_URLas an app secret. - Verify that the web process and database are on a network path that permits the connection and that the URL uses the supplied host and port.
- Place
bin/rails db:migratein the app’srelease_command, so migrations run during a release rather than once in every web process. - Deploy and use
pg_isreadyor the release logs to distinguish a database startup delay from a malformed secret.
Attaching the database and defining the migration release command solve different stages of deployment. The secret must exist before the release command starts.
Use a decision table instead of guessing
| Observed condition | Most likely cause | Fix to try first |
|---|---|---|
Exception names localhost or a local socket in production |
Missing DATABASE_URL or development defaults in database.yml |
Set the provider connection URL in production environment settings and redeploy. |
pg_isready returns status 2 |
No response at the tested host and port | Check DNS, route, firewall/security group, service state, and port. |
pg_isready returns status 1 |
Server is reachable but not accepting, often during startup or recovery | Wait, inspect database logs, and retry before changing credentials. |
| Probe succeeds but Rails still fails | Rails is using a different URL, database name, driver, or TLS setting | Compare the effective DATABASE_URL and adapter with the endpoint you tested. |
| Self-hosted database works locally but not remotely | listen_addresses=localhost, blocked port, or missing host rule |
Listen on the required private interface, allow only the app network, and review pg_hba.conf. |
| Heroku connection reaches the host but TLS fails | Client does not satisfy the platform’s TLS requirement | Use a supported TLS configuration, including sslmode=require when required. |
Run migrations only after connectivity is proven
bin/rails db:migrate opens a database connection before it can alter schema. It cannot repair a refused socket. Running it repeatedly while the endpoint is unreachable only obscures the original failure in build or release logs.
- Make the endpoint in the exception match the intended production database.
- Run
pg_isreadyagainst that exact host and port from the app’s network. - Resolve service, listener, firewall, URL, or TLS issues until the probe reports acceptance.
- Start the platform’s release, pre-deploy, or migration command.
- Check the migration output and then boot the web process.
Keep migrations in the platform’s one-time release or pre-deploy phase where available. Running them from every web process can create race conditions during scaling and does not improve connectivity.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Common mistakes and recovery steps
Changing the password first
A refused connection occurs before authentication. Restore endpoint reachability first. Change credentials only after the server answers and the resulting error identifies authentication or authorization.
Editing database.yml while DATABASE_URL is set
Rails gives the URL authority for its adapter and database values. Correct the environment variable or remove it deliberately so the YAML configuration can apply. Do not leave two conflicting production configurations.
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
Testing from a laptop only
A laptop may resolve a public hostname and have a different firewall path from a hosted web service. Run the probe from the deployment environment, a one-off task, or a machine on the same private network whenever possible.
Opening PostgreSQL to the entire internet
Making port 5432 globally reachable can hide a routing problem while creating a serious security exposure. Use private networking or a narrowly scoped firewall rule, require TLS where the provider specifies it, and restrict database roles to the permissions the app needs.
Assuming a successful build proves database access
Many builds install gems and compile assets without opening a database connection. A successful build therefore does not prove that the release command or running web process can reach PostgreSQL. Test during the release or startup stage that actually uses the database.
Ignoring startup timing
A newly created or restarted database may briefly reject connections while initializing or recovering. Status 1 from pg_isready calls for a controlled wait and log inspection, not an immediate password reset. Configure the platform’s release process to fail clearly or retry according to its documented behavior.
What to capture when the error persists
- The complete Rails exception, including host, port, and socket path, with passwords removed.
- The redacted shape of the effective
DATABASE_URLand the Rails environment name. - The exact
pg_isreadycommand and exit status from the deployment network. - Whether the database service is running, its configured port, and its listening interfaces.
- Firewall or security-group rules covering the app’s source network and database port.
- Provider release, build, and database logs around the failure time.
- The Rails, Ruby,
pggem, and PostgreSQL major versions when driver or TLS behavior is suspected.
These details separate endpoint, network, startup, TLS, and authentication failures without exposing a production secret.
Frequently Asked Questions
Why is Rails trying localhost in production?
Rails commonly falls back to the local defaults in config/database.yml when production lacks DATABASE_URL. Add the managed database URL to the service’s environment or secret settings and redeploy.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsCan a migration command fix PG::ConnectionBad?
No. A migration must connect before it can change schema. Make pg_isready succeed against the production endpoint first, then run the platform’s release or pre-deploy migration command.
Does connection refused mean my PostgreSQL password is wrong?
Usually not. Refusal indicates that no server accepted a connection at the requested endpoint. Password errors occur later, after PostgreSQL is reachable.
What port does PostgreSQL use by default?
The default TCP port is 5432. Always use the port in the provider’s connection string or PostgreSQL configuration if it differs.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

