The nearest airport is in San Francisco Intl. Airport (SFO), located 5.9 mi (9.4 km) from the city center. If you can't find a flight that works for your travel itinerary, you could also fly into Oakland Intl. Airport (OAK), which is 12.1 mi (19.5 km) away.
If you'd prefer to travel by train, the main station is Hayward Park Station.