While just about every other document is accessible online, a lost passport is one of the last analog emergencies that can derail an international trip.

Here’s a guide to replacing a lost passport according to how fast you need it, how much money you have to spare and where you live. (The process for last-minute renewals of expired passports, by the way, is fairly similar.)

If you’ve got at least three weeks

You’ll be OK. On the State Department website, at travel.state.gov/passports, first report your passport lost and then follow the process for a replacement. On the website, you’ll find a list of 7,500 passport acceptance facilities — including post offices, public libraries and clerk of court offices — where you can make an appointment or, in most cases, come during scheduled walk-in hours. They’ll verify your documents and send them to the State Department, and you’ll get your passport in the mail.

Before the day of your appointment, check what you need to bring, a list that will include at least proof of U.S. citizenship, payment (acceptable forms vary by facility), the right forms (for lost passports, that’s the DS-11 and DS-64) and at most facilities, a properly taken photo.

The “routine” processing time to replace a passport takes six to eight weeks and costs $165; choose the “expedited” service, for an additional $60, to receive your passport in two to three weeks.

You might even get yours “faster than advertised,” said Matt Pierce, a managing director of passport services for the State Department, noting that the pandemic-era backlog was cleared up as of December.

Avoid delays by carefully following instructions, and consider spending an additional $19.53 for faster shipping.

When time is tighter

If your trip is less than three weeks away, you’ll need to take the extra step of going through one of 26 passport processing offices across the United States. If you’re doing it without an outside expediter, you must make an appointment online or over the phone, up to 14 days in advance of your trip.

There are no more walk-ins, an option before the pandemic, but the State Department has increased capacity to eliminate the need for them, Pierce said, and the offices give special priority to documented “life-or-death emergencies” of immediate family members. You’ll need to bring all of your documents, and proof you are traveling soon — like a plane or cruise reservation.

Things can get dicey if you need an appointment in the next day or two. In such cases you can call for an appointment, or contact your local member of Congress.

Laurie Lee, CEO of Chicago-based Swift Passport and Visa Services, an expediter, has seen cases where clients on the verge of missing a wedding or another once-in-a-lifetime event spend hours refreshing the site to find a last-minute appointment, and even end up booking flights across the country if they can find an opening. That, of course, costs both time and money.

At the passport office, the process will be similar, except that you’ll likely be able to pick up your passport later in the day. In most cases, said Pierce, you won’t have to return the next day, but it can happen. (You can also have your passport mailed to you, if you have time.)

Using an expediter

If you have at least three business days and are willing to spend hundreds of dollars for help, consider Swift or one of the other 200-plus agencies registered with the State Department as couriers, or expediters.

Expediters are especially helpful for people who live far from the nearest passport office and cannot or do not want to drive or fly there. But they can also benefit anyone having trouble getting a timely appointment, because they have reserved slots that allow them to bring a client application directly to certain passport offices. Swift, for example, can bring 10 applications a day to the Boston office and five to the Chicago one. Depending on urgency, Swift’s assistance costs between $155 and $599.

To work with an expediter, you will still need to go to your local passport acceptance facility, like a post office, where workers verify and seal your documents in an envelope, which you then send (or hand-deliver) to the expediter. They’ll take care of the rest, and get your new passport back to you.

What can go wrong

If you’re traveling to a passport agency, leave plenty of time to get there. Screwing up something on the form can also lead to delays that can cost you your trip.

“Common errors include signing in the wrong place, not putting the date on their application, having an incorrectly sized passport photo or not being framed correctly in the photo,” said Steve Diehl, chief corporate development officer of CIBTvisas, a large expediter.

Once you get it

When your passport arrives, make digital and paper copies. Change your number on trusted traveler programs like Global Entry, and remember that if your old passport had a visa in it for the country you’re headed to, you’ll also need to rush a replacement of that.

If you do find your old passport later, keep it as a souvenir: It is no longer valid.

If you lose it while abroad

First of all, try not to. Unless you are traveling in a country that strictly requires you to have your passport on your person at all times, stow it in a hotel safe and carry around a photocopy, plus your driver’s license.

But if you do lose the passport or have it stolen, report it online to protect yourself from identity theft and then contact the nearest U.S. embassy or consulate for an emergency appointment.

You’ll need that paper or a digital copy of your passport, plus similar documents to what you would need for a replacement in the United States.

You may receive either an actual replacement passport or an emergency version, usually good for one year.

In a real emergency, you can try a last-ditch maneuver: Ask the airline to contact U.S. Customs and Border Protection to seek permission for you to enter the country without a passport.

Preventive measures

Several expediters advised that many of their clients misplaced their passports during recent moves, so when you pack up your home, be sure to remember where your passport is packed.

Oh, and before you give up on that lost passport, check your home copier or scanner.

“I can’t tell you how often people find it in their copy machine,” Lee said.